'If the user partition is deleted (or its id is changed), there\'s no
referential integrity enforced, so any references from cohorts to that
partition\'s groups will be lost.  A warning should be logged when links
are found from cohorts to partitions that do not exist.'

def test_missing_partition(self):

    self.setup_student_in_group_0()
    new_user_partition = UserPartition(1, 'Moved    Partition', 'dummy', [Group(10, 'Group    10'), Group(20, 'Group    20')], scheme=CohortPartitionScheme)
    with patch('openedx.core.djangoapps.course_groups.partition_scheme.log') as mock_log:
        self.assert_student_in_group(None, new_user_partition)
        self.assertTrue(mock_log.warn.called)
        self.assertRegexpMatches(mock_log.warn.call_args[0][0], 'partition    mismatch')
