'Scenario: In a course with content groups, if a cohort is associated with a content group that no longer
exists, a warning message is shown
Given I have a course with a cohort defined and content groups defined
When I create a new cohort and link it to a content group
And I delete that content group from the course
And I reload the page
And I view the cohort in the instructor dashboard and select settings
Then the settings display a message that the content group no longer exists
And when I select a different content group and save
Then the error message goes away'

def test_missing_content_group(self):

    new_cohort = 'linked    to    missing    content    group'
    self._create_new_cohort_linked_to_content_group(new_cohort, 'Apples')
    self.course_fixture._update_xblock(self.course_fixture._course_location, {'metadata': {u'user_partitions': [create_user_partition_json(0, 'Apples,    Bananas', 'Content    Group    Partition', [Group('2', 'Pears'), Group('1', 'Bananas')], scheme='cohort')]}})
    self.browser.refresh()
    self.cohort_management_page.wait_for_page()
    self.cohort_management_page.select_cohort(new_cohort)
    self.assertEqual('Deleted    Content    Group', self.cohort_management_page.get_cohort_associated_content_group())
    self.assertEquals(['Bananas', 'Pears', 'Deleted    Content    Group'], self.cohort_management_page.get_all_content_groups())
    self.assertEqual('Warning:\nThe    previously    selected    content    group    was    deleted.    Select    another    content    group.', self.cohort_management_page.get_cohort_related_content_group_message())
    self.cohort_management_page.set_cohort_associated_content_group('Pears')
    confirmation_messages = self.cohort_management_page.get_cohort_settings_messages()
    self.assertEqual(['Saved    cohort'], confirmation_messages)
    self.assertIsNone(self.cohort_management_page.get_cohort_related_content_group_message())
    self.assertEquals(['Bananas', 'Pears'], self.cohort_management_page.get_all_content_groups())
