def test_init(self, mock_super):
     from datacom.week01 import LED as BaseLED
     from datacom.week02 import LED
     assert self.uut._brightness == self.BRIGHTNESS, "Brightness member variable set incorrectly"
     self.assertEqual(self.uut._pwm, MockRPi.GPIO.PWM(),
                      "PWM protected member variable not set correctly")
     assert MockRPi.GPIO.PWM.call_args_list[0] == call(
         self.PIN, 1000), "PWM object not setup correctly"
     self.uut._pwm.start.assert_called_once_with(
         0), "Missing call to start PWM object"
     MockRPi.reset_mock()
     led = LED(self.PIN)
     assert isinstance(led, BaseLED), "Invalid class inheritance"
     assert led._brightness == 100, "Brightness member variable default value incorrect"
     mock_super.assert_called_once_with(
         self.PIN), "Missing call to superclass init"
Exemplo n.º 2
0
 def setUp(self):
     from datacom.week02 import LED
     MockRPi.GPIO.reset_mock()
     self.uut = LED(self.PIN, self.BRIGHTNESS)
Exemplo n.º 3
0
 def test_del(self):
     from datacom.week02 import LED
     led = LED(self.PIN)
     del led
     self.uut._pwm.stop.assert_called_once_with(
     ), "Missing call to stop PWM object"