... |
... |
@@ -3,6 +3,7 @@ import pytest |
3
|
3
|
from tests.testutils import cli
|
4
|
4
|
|
5
|
5
|
from buildstream import _yaml
|
|
6
|
+from buildstream._frontend.app import App
|
6
|
7
|
from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
7
|
8
|
from buildstream._versions import BST_FORMAT_VERSION
|
8
|
9
|
|
... |
... |
@@ -98,3 +99,34 @@ def test_bad_element_path(cli, tmpdir, element_path): |
98
|
99
|
'init', '--project-name', 'foo', '--element-path', element_path
|
99
|
100
|
])
|
100
|
101
|
result.assert_main_error(ErrorDomain.APP, 'invalid-element-path')
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+@pytest.mark.parametrize("element_path", [('foo'), ('foo/bar')])
|
|
105
|
+def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path):
|
|
106
|
+ project = tmp_path
|
|
107
|
+ project_conf_path = project.joinpath('project.conf')
|
|
108
|
+
|
|
109
|
+ class DummyInteractiveApp(App):
|
|
110
|
+ def __init__(self, *args, **kwargs):
|
|
111
|
+ super().__init__(*args, **kwargs)
|
|
112
|
+ self.interactive = True
|
|
113
|
+
|
|
114
|
+ @classmethod
|
|
115
|
+ def create(cls, *args, **kwargs):
|
|
116
|
+ return DummyInteractiveApp(*args, **kwargs)
|
|
117
|
+
|
|
118
|
+ def _init_project_interactive(self, *args, **kwargs):
|
|
119
|
+ return ('project_name', '0', element_path)
|
|
120
|
+
|
|
121
|
+ monkeypatch.setattr(App, 'create', DummyInteractiveApp.create)
|
|
122
|
+
|
|
123
|
+ result = cli.run(project=str(project), args=['init'])
|
|
124
|
+ result.assert_success()
|
|
125
|
+
|
|
126
|
+ full_element_path = project.joinpath(element_path)
|
|
127
|
+ assert full_element_path.exists()
|
|
128
|
+
|
|
129
|
+ project_conf = _yaml.load(str(project_conf_path))
|
|
130
|
+ assert project_conf['name'] == 'project_name'
|
|
131
|
+ assert project_conf['format-version'] == '0'
|
|
132
|
+ assert project_conf['element-path'] == element_path
|