def test_start_not_install(self):
        bc = Faucet('f', data=self.valid_data)
        bc._get_container = MagicMock()
        bc.api = MagicMock()
        bc._block_creator.schedule_action = MagicMock()
        bc._write_caddyfile = MagicMock()

        with pytest.raises(StateCheckError):
            bc.start()
    def test_start(self):
        bc = Faucet('f', data=self.valid_data)
        bc.state.set('actions', 'install', 'ok')
        bc._get_container = MagicMock()
        bc.api = MagicMock()
        bc._block_creator.schedule_action = MagicMock()
        bc.write_caddyfile = MagicMock()

        bc.start()

        bc._get_container.assert_called_once()
        assert bc.write_caddyfile.called

        bc.state.check('status', 'running', 'ok')
        bc.state.check('actions', 'start', 'ok')
 def test_upgrade(self):
     bc = Faucet('f', data=self.valid_data)
     bc.stop = MagicMock()
     bc.start = MagicMock()
     bc.upgrade("myflist")
     bc.stop.assert_called_once()
     bc.start.assert_called_once()
     assert bc.data['faucetFlist'] == 'myflist'