Exemplo n.º 1
0
 def test__sort_2(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     entity.add(Entity("bar"))
     entity._sort("id", True)
     self.assertEqual(["foo", "bar"], [e.id for e in entity])
Exemplo n.º 2
0
 def test__inplace_2(self):
     entity = Entity("foo")
     entity_inplace = entity._inplace(False)
     self.assertNotEqual(entity, entity_inplace)
Exemplo n.º 3
0
 def test__sort_1(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     entity.add(Entity("bar"))
     entity._sort("id", False)
     self.assertEqual(["bar", "foo"], [e.id for e in entity])
Exemplo n.º 4
0
 def test_contains_1(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     self.assertTrue("foo" in entity)
Exemplo n.º 5
0
 def test__inplace_1(self):
     entity = Entity("foo")
     entity_inplace = entity._inplace(True)
     self.assertEqual(entity, entity_inplace)
Exemplo n.º 6
0
 def test_remove_1(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     entity.remove("foo")
     self.assertFalse("foo" in entity)
Exemplo n.º 7
0
 def test_delitem_3(self):
     entity = Entity("test")
     with self.assertRaises(KeyError):
         del entity["foo"]
Exemplo n.º 8
0
 def test_full_id_3(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     entity[0].add(Entity("bar"))
     self.assertEqual(("test", "foo", "bar"), entity[0][0].full_id)
Exemplo n.º 9
0
 def test_id_1(self):
     entity = Entity("test")
     self.assertEqual("test", entity.id)
Exemplo n.º 10
0
 def test_child_dict_1(self):
     entity = Entity("test")
     child_entity1 = Entity("foo")
     entity.add(child_entity1)
     self.assertDictEqual({"foo": child_entity1}, entity.child_dict)
Exemplo n.º 11
0
 def test_full_id_2(self):
     entity = Entity("test")
     self.assertEqual(("test", ), entity.full_id)
Exemplo n.º 12
0
 def test_child_list_1(self):
     entity = Entity("test")
     child_entity1 = Entity("foo")
     entity.add(child_entity1)
     self.assertEqual(1, len(entity.child_list))
     self.assertEqual([child_entity1], entity.child_list)
Exemplo n.º 13
0
 def test_len_2(self):
     entity = Entity("test")
     self.assertEqual(0, len(entity))
Exemplo n.º 14
0
 def test_len_1(self):
     entity = Entity("test")
     for i in range(10):
         entity.add(Entity("foo_{0}".format(i)))
     self.assertEqual(10, len(entity))
Exemplo n.º 15
0
 def test_delitem_1(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     del entity["foo"]
     self.assertFalse("foo" in entity)
Exemplo n.º 16
0
 def test_id_2(self):
     entity = Entity((1, 2))
     self.assertEqual((1, 2), entity.id)
Exemplo n.º 17
0
 def test__sort_3(self):
     entity = Entity("test")
     entity.add(Entity("foo"))
     entity.add(Entity("bar"))
     with self.assertRaises(ValueError):
         entity._sort("test", True)
Exemplo n.º 18
0
 def test_id_3(self):
     entity = Entity([1, 2])
     self.assertEqual((1, 2), entity.id)
Exemplo n.º 19
0
 def test_remove_3(self):
     entity = Entity("test")
     with self.assertRaises(KeyError):
         entity.remove("foo")
Exemplo n.º 20
0
 def test_id_4(self):
     entity = Entity((1.0, 2.0))
     self.assertEqual((1.0, 2.0), entity.id)
Exemplo n.º 21
0
 def test_getitem_1(self):
     entity = Entity("test")
     child_entity = Entity("foo")
     entity.add(child_entity)
     self.assertEqual(child_entity, entity["foo"])
Exemplo n.º 22
0
 def test_iter_1(self):
     entity = Entity("test")
     for i in range(10):
         entity.add(Entity("foo_{0}".format(i)))
     for i, e in enumerate(entity):
         self.assertEqual("foo_{0}".format(i), e.id)