From ae9fc14795205456f1ccd99d7304fec69ec1b58d Mon Sep 17 00:00:00 2001 From: Mikhail Gordeev Date: Mon, 20 Apr 2020 17:27:33 +0300 Subject: [PATCH] Change CB initialization --- cloud-build.py | 2 +- cloud_build/cloud_build.py | 15 ++++++++++----- tests/test_integration_images.py | 5 ++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cloud-build.py b/cloud-build.py index 29aefbc..5f404c0 100755 --- a/cloud-build.py +++ b/cloud-build.py @@ -30,7 +30,7 @@ def parse_args(): def main(): args = parse_args() - cb = cloud_build.CB(args) + cb = cloud_build.CB(config=args.config, no_tests=args.no_tests) cb.create_images() cb.copy_external_files() cb.sign() diff --git a/cloud_build/cloud_build.py b/cloud_build/cloud_build.py index 1760d5c..b6f0318 100755 --- a/cloud_build/cloud_build.py +++ b/cloud_build/cloud_build.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -from typing import Dict, List, Any, Union +from typing import Dict, List, Union from pathlib import Path import contextlib @@ -29,12 +29,17 @@ class Error(Exception): class CB: """class for building cloud images""" - def __init__(self, args: Any) -> None: + def __init__( + self, + config, + no_tests=False, + create_remote_dirs=False + ) -> None: self.initialized = False self._save_cwd = os.getcwd() - self.parse_config(args.config) - self.no_tests = getattr(args, 'no_tests', False) - self._create_remote_dirs = getattr(args, 'create_remote_dirs', False) + self.parse_config(config) + self.no_tests = no_tests + self._create_remote_dirs = create_remote_dirs data_dir = (Path(self.expand_path(os.getenv('XDG_DATA_HOME', '~/.local/share'))) diff --git a/tests/test_integration_images.py b/tests/test_integration_images.py index 59c1ddd..1b5fba1 100644 --- a/tests/test_integration_images.py +++ b/tests/test_integration_images.py @@ -1,6 +1,5 @@ from contextlib import ExitStack from pathlib import Path -from types import SimpleNamespace from unittest import TestCase from unittest import mock @@ -28,11 +27,11 @@ class TestIntegrationImages(TestCase): {'XDG_DATA_HOME': cls.work_dir.as_posix()} )) - cloud_build = CB(SimpleNamespace( + cloud_build = CB( config='tests/test_integration_images.yaml', no_tests=True, create_remote_dirs=True, - )) + ) cloud_build.create_images() cloud_build.copy_external_files() cloud_build.sign()