Exemplo n.º 1
0
    def test_cleanup_WhenCalled_GPIOCleanupIsCalled(self):
        mockGPIO = Mock()

        lp = LightProvider(mockGPIO)
        lp.cleanup()

        self.assertTrue(mockGPIO.cleanup.called)
Exemplo n.º 2
0
    def test_lightPin_WhenCalled_PinSetToHigh(self):
        mockGPIO = Mock()

        lp = LightProvider(mockGPIO)
        lp.lightPin(LightProvider.RED_PIN())

        mockGPIO.output.assert_called_once_with(LightProvider.RED_PIN(), mockGPIO.HIGH)
Exemplo n.º 3
0
    def test_clearPins(self):
        mockGPIO = Mock()

        lp = LightProvider(mockGPIO)
        lp.clearPins()

        mockGPIO.output.assert_any_call(LightProvider.RED_PIN(), mockGPIO.LOW)
        mockGPIO.output.assert_any_call(LightProvider.GREEN_PIN(), mockGPIO.LOW)
        mockGPIO.output.assert_any_call(LightProvider.YELLOW_PIN(), mockGPIO.LOW)
Exemplo n.º 4
0
    def test_setupGPIO(self):
        mockGPIO = Mock()

        lp = LightProvider(mockGPIO)
        lp.setupGPIO()

        self.assertTrue(mockGPIO.output.called)
        mockGPIO.setmode.assert_any_call(mockGPIO.BCM)
        mockGPIO.setup.assert_any_call(LightProvider.RED_PIN(), mockGPIO.OUT)
        mockGPIO.setup.assert_any_call(LightProvider.GREEN_PIN(), mockGPIO.OUT)
        mockGPIO.setup.assert_any_call(LightProvider.YELLOW_PIN(), mockGPIO.OUT)
        mockGPIO.output.assert_any_call(LightProvider.RED_PIN(), mockGPIO.LOW)
        mockGPIO.output.assert_any_call(LightProvider.GREEN_PIN(), mockGPIO.LOW)
        mockGPIO.output.assert_any_call(LightProvider.YELLOW_PIN(), mockGPIO.LOW)
Exemplo n.º 5
0
                self.lights.clearPins()
                self.lights.cleanup()

        if self.isDisplayTime:
            try:
                status = self.getStatusToDisplay()
                self.lights.clearPins()
                self.lights.lightPin(self.getPinToLightUp(status))
            except KeyboardInterrupt:
                self.lights.cleanup()
            except:
                print 'Unhandled error occurred: ', sys.exc_info()[0]

if __name__ == '__main__':
    try:

        appConfig = AppConfig()
        lights = LightProvider(GPIO)
        tc = TeamCityProvider(requests, appConfig, 'jgarrison', 'password')
        tv = TimeValidator(datetime, WEHolidays())
        buildLights = TCBuildLights(lights, tc, tv)

        lights.setupGPIO()

        while 1:
            buildLights.main()
            time.sleep(5)

    except KeyboardInterrupt:
        lights.cleanup()