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'
    def test_stop(self):
        bc = Faucet('f', data=self.valid_data)
        bc.state.set('actions', 'start', 'ok')
        bc.state.set('status', 'running', 'ok')

        bc.api = MagicMock()
        bc._container_sal.stop = MagicMock()
        bc._block_creator.schedule_action = MagicMock()

        bc.stop()

        bc._container_sal.stop.assert_called_once()
        bc._block_creator.schedule_action.assert_called_once_with("stop")

        with pytest.raises(StateCheckError):
            bc.state.check('status', 'running', 'ok')
            bc.state.check('actions', 'start', 'ok')