@@ -198,6 +198,7 @@ def test_pip_source_build(cli, datafiles, setup_pypi_repo):
198198 pypi_repo = os .path .join (project , "files" , "pypi-repo" )
199199 os .makedirs (pypi_repo , exist_ok = True )
200200 setup_pypi_repo (mock_packages , pypi_repo )
201+ realpath_repo = os .path .realpath (pypi_repo )
201202
202203 element = {
203204 "kind" : "manual" ,
@@ -206,7 +207,7 @@ def test_pip_source_build(cli, datafiles, setup_pypi_repo):
206207 {"kind" : "local" , "path" : "files/pip-source" },
207208 {
208209 "kind" : "pip" ,
209- "url" : "file://{}" .format (os . path . realpath ( pypi_repo ) ),
210+ "url" : "file://{}" .format (realpath_repo ),
210211 "requirements-files" : ["myreqs.txt" ],
211212 "packages" : dependencies ,
212213 },
@@ -227,9 +228,36 @@ def test_pip_source_build(cli, datafiles, setup_pypi_repo):
227228 result = cli .run (project = project , args = ["source" , "track" , element_name ])
228229 assert result .exit_code == 0
229230
231+ #
232+ # Lets sneak in here and test out that Source.collect_source_info() works as expected
233+ #
234+ # The ref for this generated pip source is:
235+ #
236+ # "app2==0.1\napp_3==0.1\napp_4==0.1\napp_5==0.1\napp_no_6==0.1\napp_no_7==0.1\napp_no_8==0.1\nhellolib==0.1"
237+ #
238+ # Lets just make an assertion on the first dependency app2, which is the second in the list after the local source for this element
239+ #
240+ result = cli .run (
241+ project = project ,
242+ silent = True ,
243+ args = ["show" , "--deps" , "none" , "--format" , "element:\n %{source-info}" , element_name ],
244+ )
245+ result .assert_success ()
246+ loaded = _yaml .load_data (result .output )
247+ sources = loaded .get_sequence ("element" )
248+ source_info = sources .mapping_at (1 )
249+ assert source_info .get_str ("kind" ) == "pip"
250+ assert source_info .get_str ("url" ) == f"file://{ realpath_repo } /project/app2"
251+ assert source_info .get_str ("medium" ) == "pypi"
252+ assert source_info .get_str ("version-type" ) == "indexed-version"
253+ assert source_info .get_str ("version" ) == "0.1"
254+ assert source_info .get_str ("version-guess" ) == "0.1"
255+
256+ # Go ahead and build
230257 result = cli .run (project = project , args = ["build" , element_name ])
231258 assert result .exit_code == 0
232259
260+ # Use a build shell to assert the output of something we installed
233261 result = cli .run (project = project , args = ["shell" , element_name , "/usr/bin/app1.py" ])
234262 assert result .exit_code == 0
235263 assert result .output == "Hello App1! This is hellolib\n "
0 commit comments