'Test the validation messages produced for a component whose
access settings contradict the unit level access.'

def test_validate_nonsensical_access_restriction(self):

    self.set_group_access(self.vertical_location, {self.user_partition.id: [self.group1.id]})
    self.set_group_access(self.video_location, {self.user_partition.id: [self.group1.id]})
    validation = self.store.get_item(self.video_location).validate()
    self.assertEqual(len(validation.messages), 0)
    self.set_group_access(self.vertical_location, {self.user_partition.id: [self.group1.id]})
    self.set_group_access(self.video_location, {self.user_partition.id: [self.group2.id]})
    validation = self.store.get_item(self.video_location).validate()
    self.assertEqual(len(validation.messages), 1)
    self.verify_validation_message(validation.messages[0], NONSENSICAL_ACCESS_RESTRICTION, ValidationMessage.ERROR)
    self.set_group_access(self.vertical_location, {self.user_partition.id: [self.group1.id]})
    self.set_group_access(self.video_location, {self.user_partition.id: [self.group1.id, self.group2.id]})
    validation = self.store.get_item(self.video_location).validate()
    self.assertEqual(len(validation.messages), 1)
    self.verify_validation_message(validation.messages[0], NONSENSICAL_ACCESS_RESTRICTION, ValidationMessage.ERROR)
    self.set_group_access(self.vertical_location, {self.user_partition.id: [self.group1.id]})
    self.set_group_access(self.video_location, {})
    validation = self.store.get_item(self.video_location).validate()
    self.assertEqual(len(validation.messages), 1)
    self.verify_validation_message(validation.messages[0], NONSENSICAL_ACCESS_RESTRICTION, ValidationMessage.ERROR)
