예제 #1
0
 def test_hash(self):
     outer_pin = sdn.OuterPin()
     self.assertEqual(hash(outer_pin), hash(self.pin))
     inner_pin = sdn.InnerPin()
     instance = sdn.Instance()
     outer_pin1 = sdn.OuterPin.from_instance_and_inner_pin(
         instance, inner_pin)
     outer_pin2 = sdn.OuterPin.from_instance_and_inner_pin(
         instance, inner_pin)
     self.assertEqual(hash(outer_pin1), hash(outer_pin2))
예제 #2
0
 def test_equal(self):
     outer_pin = sdn.OuterPin()
     self.assertEqual(outer_pin, self.pin)
     inner_pin = sdn.InnerPin()
     instance = sdn.Instance()
     outer_pin1 = sdn.OuterPin.from_instance_and_inner_pin(
         instance, inner_pin)
     outer_pin2 = sdn.OuterPin.from_instance_and_inner_pin(
         instance, inner_pin)
     self.assertEqual(outer_pin1, outer_pin2)
     self.assertNotEqual(self.pin, outer_pin1)
     self.assertNotEqual(self.pin, None)
예제 #3
0
    def test_connect_and_disconnect_outer_pin_by_object(self):
        self.wire.connect_pin(sdn.OuterPin.from_instance_and_inner_pin(
            self.instance, self.pin2),
                              position=0)
        self.assertEqual(len(self.wire.pins), 1)
        self.assertTrue(all(x is self.instance.pins[x]
                            for x in self.wire.pins))
        self.assertTrue(all(x.wire is self.wire for x in self.wire.pins))
        self.assertTrue(
            all(x.instance is self.instance for x in self.wire.pins))
        self.assertEqual(self.instance.pins[self.pin2].inner_pin, self.pin2)

        self.wire.disconnect_pin(sdn.OuterPin(self.instance, self.pin2))
        self.assertEqual(len(self.wire.pins), 0)
        self.assertFalse(self.instance.pins[self.pin2] in self.wire.pins)
        self.assertIsNone(self.instance.pins[self.pin1].wire)
        self.assertTrue(self.pin1 in self.instance.pins)
예제 #4
0
 def test_disconnect_outer_pin_from_outside_wire(self):
     outer_pin = sdn.OuterPin()
     self.wire.disconnect_pins_from([outer_pin])
예제 #5
0
 def setUp(self) -> None:
     self.pin = sdn.OuterPin()
 def test_get(self):
     self.assertEqual(self.outer_pins_view.get(self.inner_pins[0]), sdn.OuterPin(self.instance, self.inner_pins[0]))
     self.assertEqual(self.outer_pins_view.get(sdn.OuterPin(self.instance, self.inner_pins[0])),
                      sdn.OuterPin(self.instance, self.inner_pins[0]))
 def test_getitem(self):
     self.assertTrue(all(self.outer_pins_view[x] == sdn.OuterPin(self.instance, x) for x in self.inner_pins))
     self.assertTrue(all(self.outer_pins_view[x] is self.outer_pins_view[sdn.OuterPin(self.instance, x)] for x in
                         self.inner_pins))
 def test_equal(self):
     self.assertEqual(self.outer_pins_view, dict(map(lambda x: (x, sdn.OuterPin(self.instance, x)),
                                                     self.inner_pins)))
 def test_contains(self):
     self.assertTrue(all(x in self.outer_pins_view for x in self.inner_pins))
     self.assertTrue(all(sdn.OuterPin(self.instance, x) in self.outer_pins_view for x in self.inner_pins))