Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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')
Beispiel #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')
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)