Esempio n. 1
0
 def test_activate(self):
     wb = fastwire.WireBox()
     cid1 = wb.add()
     cid2 = wb.add(3049)
     wb.set_active(cid1)
     check = wb._active
     self.assertEqual(cid1, check)
Esempio n. 2
0
    def test_remove_with(self):
        class A():
            pass

        a = A()
        wb = fastwire.WireBox()
        wb.add(id(a), remove_with=a)
        self.assertEqual(len(wb._cs), 2)
        del a
        self.assertEqual(len(wb._cs), 1)
Esempio n. 3
0
 def test_get_repeated(self):
     wb = fastwire.WireBox()
     wc = wb.add(id(self))
     wire_1 = wb.get('this_name')
     wire_2 = wb.get('this_name')
     self.assertEqual(wire_1, wire_2)
Esempio n. 4
0
 def test_get(self):
     wb = fastwire.WireBox()
     wc = wb.add(id(self))
     wire = wb.get('this_name')
     self.assertEqual(wire.name, 'this_name')
     self.assertEqual(wire.__class__, fastwire.Wire)
Esempio n. 5
0
 def test_create_on_demand_repeated(self):
     wb = fastwire.WireBox()
     wc = wb.add(id(self))
     wire_1 = wb['this_name']
     wire_2 = wb['this_name']
     self.assertEqual(wire_1, wire_2)
Esempio n. 6
0
 def test_create_on_demand(self):
     wb = fastwire.WireBox()
     wc = wb.add(id(self))
     wire = wb['this_name']
     self.assertEqual(wire.name, 'this_name')
     self.assertEqual(wire.__class__, fastwire.Wire)
Esempio n. 7
0
 def test_get_attrs_kwarg(self):
     dct = {'a': 5}
     wb = fastwire.WireBox()  # use default container
     wire = wb.get(name='test_name', attrs=dct)
     self.assertEqual(wire.attrs, dct)
Esempio n. 8
0
 def test_get_doc_kwarg(self):
     wb = fastwire.WireBox()  # use default container
     wire = wb.get(name='test_name', doc='test_doc')
     self.assertEqual(wire.doc, 'test_doc')
Esempio n. 9
0
 def test_get_name_arg(self):
     wb = fastwire.WireBox()  # use default container
     wire = wb.get('test_name')
     self.assertEqual(wire.name, 'test_name')
Esempio n. 10
0
 def test_create_cid_str(self):
     b = fastwire.WireBox()
     c = b.add('a_string')
     self.assertEqual(c.__class__, fastwire.WireContainer)
     self.assertEqual(c.id, 'a_string')
     self.assertEqual(b.get_container('a_string'), c)
Esempio n. 11
0
 def test_create_cid_int(self):
     b = fastwire.WireBox()
     c = b.add(456)
     self.assertEqual(c.__class__, fastwire.WireContainer)
     self.assertEqual(c.id, 456)
     self.assertEqual(b.get_container(456), c)
Esempio n. 12
0
 def test_create_auto(self):
     b = fastwire.WireBox()
     c = b.add()
     self.assertEqual(c.__class__, fastwire.WireContainer)
     self.assertEqual(c.id, 1)
     self.assertEqual(b.get_container(0), c)
Esempio n. 13
0
 def test_remove(self):
     wb = fastwire.WireBox()
     wb.add(0)
     self.assertEqual(len(wb._cs), 2)
     wb.remove(0)
     self.assertEqual(len(wb._cs), 1)