def test_list_builders_are_independent(self): """Test that adding to one List Builder does not affect another one""" test_object1 = EntityListBuilder('none') test_object2 = EntityListBuilder('none') test_object1.get_or_create_entity("A") self.assertEqual(1, len(test_object1.entities())) self.assertEqual(0, len(test_object2.entities())) test_object2.get_or_create_entity("A") self.assertEqual(1, len(test_object1.entities())) self.assertEqual(1, len(test_object2.entities()))
def test_different_object_retrieved_for_case_different_name(self): """ Test that we get a different object from the get_or_create_entity() function when we give names differing in case. """ test_object = EntityListBuilder('none') entity_upper_a = test_object.get_or_create_entity("A") entity_lower_a = test_object.get_or_create_entity("a") count = len(test_object.entities()) self.assertEqual(2, count, "Should be 2 objects in the list of " "entities") self.assertFalse(entity_upper_a == entity_lower_a, "Should be different objects") self.assertTrue(entity_lower_a in test_object.entities()) self.assertTrue(entity_upper_a in test_object.entities())
def test_only_one_object_created_for_single_name(self): """ Test that only one object is created by the get_or_create_entity() function when we give the same name multiple times. """ test_object = EntityListBuilder('none') test_object.get_or_create_entity("A") test_object.get_or_create_entity("A") test_object.get_or_create_entity("A") test_object.get_or_create_entity("A") count = len(test_object.entities()) self.assertEqual( 1, count, "Should be a single object in the list " "of entities")
def test_default_entities_is_empty(self): """Test that the default set of entities is empty""" test_object = EntityListBuilder('none') self.assertEqual(0, len(test_object.entities()))