summaryrefslogtreecommitdiff
path: root/tests/frontend/init.py
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-11-05 13:00:30 +0000
committerChandan Singh <csingh43@bloomberg.net>2019-11-05 13:00:30 +0000
commite06c2295b063245dbdb2397e5bd8c4d0a79ba10d (patch)
tree224a111e1daee5a7d450e7d5e0c31fd94c1e19c6 /tests/frontend/init.py
parentc1f423f8653c5a9e3e72283879e8cecabf25ed3f (diff)
downloadbuildstream-e06c2295b063245dbdb2397e5bd8c4d0a79ba10d.tar.gz
Blacken codebase
Diffstat (limited to 'tests/frontend/init.py')
-rw-r--r--tests/frontend/init.py151
1 files changed, 88 insertions, 63 deletions
diff --git a/tests/frontend/init.py b/tests/frontend/init.py
index 0fdc0eda5..01686b7c6 100644
--- a/tests/frontend/init.py
+++ b/tests/frontend/init.py
@@ -13,114 +13,137 @@ from buildstream._versions import BST_FORMAT_VERSION
def test_defaults(cli, tmpdir):
project = str(tmpdir)
- project_path = os.path.join(project, 'project.conf')
+ project_path = os.path.join(project, "project.conf")
- result = cli.run(args=['init', '--project-name', 'foo', project])
+ result = cli.run(args=["init", "--project-name", "foo", project])
result.assert_success()
project_conf = _yaml.load(project_path)
- assert project_conf.get_str('name') == 'foo'
- assert project_conf.get_str('format-version') == str(BST_FORMAT_VERSION)
- assert project_conf.get_str('element-path') == 'elements'
+ assert project_conf.get_str("name") == "foo"
+ assert project_conf.get_str("format-version") == str(BST_FORMAT_VERSION)
+ assert project_conf.get_str("element-path") == "elements"
def test_all_options(cli, tmpdir):
project = str(tmpdir)
- project_path = os.path.join(project, 'project.conf')
-
- result = cli.run(args=[
- 'init',
- '--project-name', 'foo',
- '--format-version', '2',
- '--element-path', 'ponies',
- project
- ])
+ project_path = os.path.join(project, "project.conf")
+
+ result = cli.run(
+ args=[
+ "init",
+ "--project-name",
+ "foo",
+ "--format-version",
+ "2",
+ "--element-path",
+ "ponies",
+ project,
+ ]
+ )
result.assert_success()
project_conf = _yaml.load(project_path)
- assert project_conf.get_str('name') == 'foo'
- assert project_conf.get_str('format-version') == str(2)
- assert project_conf.get_str('element-path') == 'ponies'
+ assert project_conf.get_str("name") == "foo"
+ assert project_conf.get_str("format-version") == str(2)
+ assert project_conf.get_str("element-path") == "ponies"
- elements_dir = os.path.join(project, 'ponies')
+ elements_dir = os.path.join(project, "ponies")
assert os.path.isdir(elements_dir)
def test_no_project_name(cli, tmpdir):
- result = cli.run(args=['init', str(tmpdir)])
- result.assert_main_error(ErrorDomain.APP, 'unspecified-project-name')
+ result = cli.run(args=["init", str(tmpdir)])
+ result.assert_main_error(ErrorDomain.APP, "unspecified-project-name")
def test_project_exists(cli, tmpdir):
project = str(tmpdir)
- project_path = os.path.join(project, 'project.conf')
- with open(project_path, 'w') as f:
- f.write('name: pony\n')
+ project_path = os.path.join(project, "project.conf")
+ with open(project_path, "w") as f:
+ f.write("name: pony\n")
- result = cli.run(args=['init', '--project-name', 'foo', project])
- result.assert_main_error(ErrorDomain.APP, 'project-exists')
+ result = cli.run(args=["init", "--project-name", "foo", project])
+ result.assert_main_error(ErrorDomain.APP, "project-exists")
def test_force_overwrite_project(cli, tmpdir):
project = str(tmpdir)
- project_path = os.path.join(project, 'project.conf')
- with open(project_path, 'w') as f:
- f.write('name: pony\n')
+ project_path = os.path.join(project, "project.conf")
+ with open(project_path, "w") as f:
+ f.write("name: pony\n")
- result = cli.run(args=['init', '--project-name', 'foo', '--force', project])
+ result = cli.run(args=["init", "--project-name", "foo", "--force", project])
result.assert_success()
project_conf = _yaml.load(project_path)
- assert project_conf.get_str('name') == 'foo'
- assert project_conf.get_str('format-version') == str(BST_FORMAT_VERSION)
+ assert project_conf.get_str("name") == "foo"
+ assert project_conf.get_str("format-version") == str(BST_FORMAT_VERSION)
def test_relative_path_directory_as_argument(cli, tmpdir):
- project = os.path.join(str(tmpdir), 'child-directory')
+ project = os.path.join(str(tmpdir), "child-directory")
os.makedirs(project, exist_ok=True)
- project_path = os.path.join(project, 'project.conf')
+ project_path = os.path.join(project, "project.conf")
rel_path = os.path.relpath(project)
- result = cli.run(args=['init', '--project-name', 'foo', rel_path])
+ result = cli.run(args=["init", "--project-name", "foo", rel_path])
result.assert_success()
project_conf = _yaml.load(project_path)
- assert project_conf.get_str('name') == 'foo'
- assert project_conf.get_int('format-version') == BST_FORMAT_VERSION
- assert project_conf.get_str('element-path') == 'elements'
+ assert project_conf.get_str("name") == "foo"
+ assert project_conf.get_int("format-version") == BST_FORMAT_VERSION
+ assert project_conf.get_str("element-path") == "elements"
def test_set_directory_and_directory_as_argument(cli, tmpdir):
- result = cli.run(args=['-C', '/foo/bar', 'init', '--project-name', 'foo', '/boo/far'])
- result.assert_main_error(ErrorDomain.APP, 'init-with-set-directory')
+ result = cli.run(
+ args=["-C", "/foo/bar", "init", "--project-name", "foo", "/boo/far"]
+ )
+ result.assert_main_error(ErrorDomain.APP, "init-with-set-directory")
-@pytest.mark.parametrize("project_name", [('Micheal Jackson'), ('one+one')])
+@pytest.mark.parametrize("project_name", [("Micheal Jackson"), ("one+one")])
def test_bad_project_name(cli, tmpdir, project_name):
- result = cli.run(args=['init', '--project-name', str(tmpdir)])
+ result = cli.run(args=["init", "--project-name", str(tmpdir)])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_SYMBOL_NAME)
@pytest.mark.parametrize("format_version", [(str(-1)), (str(BST_FORMAT_VERSION + 1))])
def test_bad_format_version(cli, tmpdir, format_version):
- result = cli.run(args=[
- 'init', '--project-name', 'foo', '--format-version', format_version, str(tmpdir)
- ])
- result.assert_main_error(ErrorDomain.APP, 'invalid-format-version')
-
-
-@pytest.mark.parametrize("element_path", [('/absolute/path'), ('../outside/of/project')])
+ result = cli.run(
+ args=[
+ "init",
+ "--project-name",
+ "foo",
+ "--format-version",
+ format_version,
+ str(tmpdir),
+ ]
+ )
+ result.assert_main_error(ErrorDomain.APP, "invalid-format-version")
+
+
+@pytest.mark.parametrize(
+ "element_path", [("/absolute/path"), ("../outside/of/project")]
+)
def test_bad_element_path(cli, tmpdir, element_path):
- result = cli.run(args=[
- 'init', '--project-name', 'foo', '--element-path', element_path, str(tmpdir)
- ])
- result.assert_main_error(ErrorDomain.APP, 'invalid-element-path')
-
-
-@pytest.mark.parametrize("element_path", [('foo'), ('foo/bar')])
+ result = cli.run(
+ args=[
+ "init",
+ "--project-name",
+ "foo",
+ "--element-path",
+ element_path,
+ str(tmpdir),
+ ]
+ )
+ result.assert_main_error(ErrorDomain.APP, "invalid-element-path")
+
+
+@pytest.mark.parametrize("element_path", [("foo"), ("foo/bar")])
def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path):
project = tmp_path
- project_conf_path = project.joinpath('project.conf')
+ project_conf_path = project.joinpath("project.conf")
class DummyInteractiveApp(App):
def __init__(self, *args, **kwargs):
@@ -131,18 +154,20 @@ def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path):
def create(cls, *args, **kwargs):
return DummyInteractiveApp(*args, **kwargs)
- def _init_project_interactive(self, *args, **kwargs): # pylint: disable=arguments-differ
- return ('project_name', '0', element_path)
+ def _init_project_interactive(
+ self, *args, **kwargs
+ ): # pylint: disable=arguments-differ
+ return ("project_name", "0", element_path)
- monkeypatch.setattr(App, 'create', DummyInteractiveApp.create)
+ monkeypatch.setattr(App, "create", DummyInteractiveApp.create)
- result = cli.run(args=['init', str(project)])
+ result = cli.run(args=["init", str(project)])
result.assert_success()
full_element_path = project.joinpath(element_path)
assert full_element_path.exists()
project_conf = _yaml.load(str(project_conf_path))
- assert project_conf.get_str('name') == 'project_name'
- assert project_conf.get_str('format-version') == '0'
- assert project_conf.get_str('element-path') == element_path
+ assert project_conf.get_str("name") == "project_name"
+ assert project_conf.get_str("format-version") == "0"
+ assert project_conf.get_str("element-path") == element_path