Пример #1
0
    def test_nullable_related_fields_collected_objects(self):

        ## First, test the CollectedObjects data structure directly
        g = CollectedObjects()
        self.assertFalse(g.add("key1", 1, "item1", None))
        self.assertFalse(g.add("key2", 1, "item1", "key1", nullable=True))
        self.assertTrue(g.add("key1", 1, "item1", "key2"))
        self.assertEqual(g.ordered_keys(), ['key1', 'key2'])
Пример #2
0
    def test_collected_objects_data_structure(self):
        ## Test the CollectedObjects data structure directly

        g = CollectedObjects()
        self.assertFalse(g.add("key1", 1, "item1", None))
        self.assertEqual(g["key1"], {1: 'item1'})
        self.assertFalse(g.add("key2", 1, "item1", "key1"))
        self.assertFalse(g.add("key2", 2, "item2", "key1"))
        self.assertEqual(g["key2"], {1: 'item1', 2: 'item2'})
        self.assertFalse(g.add("key3", 1, "item1", "key1"))
        self.assertTrue(g.add("key3", 1, "item1", "key2"))
        self.assertEqual(g.ordered_keys(), ['key3', 'key2', 'key1'])
        self.assertTrue(g.add("key2", 1, "item1", "key3"))
        self.assertRaises(CyclicDependency,
                          g.ordered_keys)
Пример #3
0
    def test_collected_objects(self):
        g = CollectedObjects()
        self.assertFalse(g.add("key1", 1, "item1", None))
        self.assertEqual(g["key1"], {1: "item1"})

        self.assertFalse(g.add("key2", 1, "item1", "key1"))
        self.assertFalse(g.add("key2", 2, "item2", "key1"))

        self.assertEqual(g["key2"], {1: "item1", 2: "item2"})

        self.assertFalse(g.add("key3", 1, "item1", "key1"))
        self.assertTrue(g.add("key3", 1, "item1", "key2"))
        self.assertEqual(g.ordered_keys(), ["key3", "key2", "key1"])

        self.assertTrue(g.add("key2", 1, "item1", "key3"))
        self.assertRaises(CyclicDependency, g.ordered_keys)
Пример #4
0
 def test_collected_objects_null(self):
     g = CollectedObjects()
     self.assertFalse(g.add("key1", 1, "item1", None))
     self.assertFalse(g.add("key2", 1, "item1", "key1", nullable=True))
     self.assertTrue(g.add("key1", 1, "item1", "key2"))
     self.assertEqual(g.ordered_keys(), ["key1", "key2"])