def test_set_create_fail(self): """Test create expected failure.""" # We should not be able to create existing labels s = AssessSet(TestItemA) s.create("a1") msg = "ERROR: Could not create item a1, as this name is used by another item." self.assertEqual(s.context['item_list_message'], msg) # Maximum label length is 10 characters s = AssessSet(TestItemA) s.create("a1234567890") msg = "ERROR: Could not create item a1234567890, as this name is longer than 10 characters." self.assertEqual(s.context['item_list_message'], msg)
def test_set_create_success(self): """Test successfull delete.""" s = AssessSet(TestItemA) s.create("a3") msg = 'SUCCESS: Created item a3.' self.assertEqual(s.context['item_list_message'], msg) self.a3 = TestItemA.objects.get(label='a3') # Test that item a1 was in fact deleted s = AssessSet(TestItemA) self.assertEqual(s.labels, ['a1', 'a2', 'a3']) self.assertEqual(s.labels_by_ids, {1: 'a1', 2: 'a2', 3: 'a3'}) self.assertEqual(s.ids_by_labels, {'a1': 1, 'a2': 2, 'a3': 3}) self.assertEqual(s.items, { 'a1': self.a1, 'a2': self.a2, 'a3': self.a3 })