'Test that moving a component with non-contradicting access
restrictions into a unit that has contradicting access
restrictions brings up the nonsensical access validation
message and that the message does not show up when moved
into a unit where the component\'s access settings do not
contradict the unit\'s access settings.'

def test_move_component_nonsensical_access_restriction_validation(self):

    group1 = self.course.user_partitions[0].groups[0]
    group2 = self.course.user_partitions[0].groups[1]
    vert2 = self.store.get_item(self.vert2_usage_key)
    html = self.store.get_item(self.html_usage_key)
    partitions_service = MockPartitionService(self.course, course_id=self.course.id)
    html.runtime._services['partitions'] = partitions_service
    vert2.group_access = {self.course.user_partitions[0].id: [group1.id]}
    html.group_access = {self.course.user_partitions[0].id: [group2.id]}
    self.store.update_item(html, self.user.id)
    self.store.update_item(vert2, self.user.id)
    validation = html.validate()
    self.assertEqual(len(validation.messages), 0)
    self.assert_move_item(self.html_usage_key, self.vert2_usage_key)
    html.parent = self.vert2_usage_key
    self.store.update_item(html, self.user.id)
    validation = html.validate()
    self.assertEqual(len(validation.messages), 1)
    self._verify_validation_message(validation.messages[0], NONSENSICAL_ACCESS_RESTRICTION, ValidationMessage.ERROR)
    self.assert_move_item(self.html_usage_key, self.vert_usage_key)
    html.parent = self.vert_usage_key
    self.store.update_item(html, self.user.id)
    validation = html.validate()
    self.assertEqual(len(validation.messages), 0)
