def test_push_raise_timeout(self, build_mock, push_mock): push_mock.side_effect = ReadTimeoutError(None, "foo", "error") with self.assertRaises(PolyaxonBuildException): build_and_push( context=".", destination="image_name:image_tag", nocache=True, max_retries=1, sleep_interval=0, ) assert build_mock.call_count == 1
def test_build_and_push(self, login_mock, build_mock, push_mock): build_and_push( context=".", destination="image_name:image_tag", nocache=True, registries=[ V1UriType("user", "pwd", "host"), V1UriType("user", "pwd", "host"), ], ) assert login_mock.call_count == 2 assert build_mock.call_count == 1 assert push_mock.call_count == 1
def build_and_push(context, destination, nocache, max_retries, sleep_interval, reraise): """ Build a dockerfile and push it to the provided registry, this command required Docker to be installed. """ from polyaxon.builds.builder import build_and_push try: build_and_push( context=context, destination=destination, nocache=nocache, max_retries=max_retries, sleep_interval=sleep_interval, ) except PolyaxonBuildException as e: handle_cli_error(e, message="Docker build and push failed") if reraise: raise e sys.exit(1)