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__get_container_not_installed(self):
        bc = Faucet('f', data=self.valid_data)
        sp = MagicMock()
        fs = MagicMock()
        fs.path = 'mypath'
        sp.get.return_value = fs
        bc._node_sal.storagepools.get = MagicMock(return_value=sp)
        bc.api = MagicMock()
        bc._node_sal.client.filesystem = MagicMock()

        bc._get_caddyfile = MagicMock()
        bc._write_caddyfile = MagicMock()

        with pytest.raises(StateCheckError):
            bc._get_container()

            bc._node_sal.client.filesystem.mkdir.assert_has_calls(
                [mock.call('mypath/wallet'),
                 mock.call('mypath/caddy-certs')])

            assert bc._node_sal.containers.create.called
            assert bc._get_caddyfile.called
    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')