Ejemplo n.º 1
0
 def test_ticks_without_messages(self, printer: StreamPrinter,
                                 capfd: Any) -> None:
     printer.tick()
     printer.close()
     out, err = capfd.readouterr()
     assert err == ""
     assert out == f".{linesep}"
Ejemplo n.º 2
0
class StreamDockerImageProgress(DockerImageProgress):
    def __init__(self) -> None:
        self._printer = StreamPrinter()

    def push(self, data: ImageProgressPush) -> None:
        self._printer.print(f"Using local image '{data.src}'")
        self._printer.print(f"Using remote image '{data.dst}'")
        self._printer.print("Pushing image...")

    def pull(self, data: ImageProgressPull) -> None:
        self._printer.print(f"Using remote image '{data.src}'")
        self._printer.print(f"Using local image '{data.dst}'")
        self._printer.print("Pulling image...")

    def step(self, data: ImageProgressStep) -> None:
        if data.layer_id:
            self._printer.tick()
        else:
            self._printer.print(data.message)

    def save(self, data: ImageProgressSave) -> None:
        self._printer.print(
            f"Saving job '{data.job}' to image '{data.dst}'...")

    def commit_started(self, data: ImageCommitStarted) -> None:
        self._printer.print(f"Using remote image '{data.target_image}'")
        self._printer.print(f"Creating image from the job container...")

    def commit_finished(self, data: ImageCommitFinished) -> None:
        self._printer.print("Image created")

    def close(self) -> None:
        self._printer.close()
Ejemplo n.º 3
0
 def test_two_messages(self, printer: StreamPrinter, capfd: Any) -> None:
     printer.print("message1")
     printer.print("message2")
     printer.close()
     out, err = capfd.readouterr()
     assert err == ""
     assert out == f"message1{linesep}message2{linesep}"
Ejemplo n.º 4
0
 def test_ticks_spam_control(self, printer: StreamPrinter, capfd: Any,
                             monkeypatch: Any) -> None:
     monkeypatch.setattr("neuromation.cli.printer.TICK_TIMEOUT", 1000)
     printer.tick()
     printer.tick()
     printer.close()
     out, err = capfd.readouterr()
     assert err == ""
     assert out == f".{linesep}"
Ejemplo n.º 5
0
 def test_ticks_with_messages(self, printer: StreamPrinter, capfd: Any,
                              monkeypatch: Any) -> None:
     monkeypatch.setattr("neuromation.cli.printer.TICK_TIMEOUT", 0)
     printer.tick()
     printer.print("message")
     printer.tick()
     printer.tick()
     printer.close()
     out, err = capfd.readouterr()
     assert err == ""
     assert out == f".{linesep}message..{linesep}"
Ejemplo n.º 6
0
 def test_one_message(self, printer: StreamPrinter, capfd: Any) -> None:
     printer.print("message")
     printer.close()
     out, err = capfd.readouterr()
     assert err == ""
     assert out == f"message{linesep}"
Ejemplo n.º 7
0
 def test_no_messages(self, printer: StreamPrinter, capfd: Any) -> None:
     printer.close()
     out, err = capfd.readouterr()
     assert err == ""
     assert out == ""