diff options
| author | mo khan <mo.khan@gmail.com> | 2020-03-31 13:28:27 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-04-01 10:05:54 -0600 |
| commit | 4e4462a6f2052fc7cc5ffe1b4b677ef1af1749b9 (patch) | |
| tree | e52b1d2e83000aa5d4cb050fa8d2f0cc647b94be /spec | |
| parent | d6b721605bfe75d735abe80f365822075f49fa23 (diff) | |
Pull package info from sources in Pipfile.lock
* Exclude dependencies in "develop" group"
* Install pipenv by default
* Use .venv to match the default location as pipenv
* Use pip-licenses to detect licenses in Pipfile project
* Add variation of the MIT License
* Redirect asdf install stdout to /dev/null
* Add CHANGELOG entry and bump version
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/fixtures/expected/python/pipenv/v1.0.json | 2 | ||||
| -rw-r--r-- | spec/fixtures/expected/python/pipenv/v1.1.json | 2 | ||||
| -rw-r--r-- | spec/fixtures/expected/python/pipenv/v2.0.json | 2 | ||||
| -rw-r--r-- | spec/fixtures/python/simple-Pipfile | 10 | ||||
| -rw-r--r-- | spec/fixtures/python/simple-Pipfile.lock | 69 | ||||
| -rw-r--r-- | spec/integration/python/pipenv_spec.rb | 69 | ||||
| -rw-r--r-- | spec/support/integration_test_helper.rb | 2 |
7 files changed, 143 insertions, 13 deletions
diff --git a/spec/fixtures/expected/python/pipenv/v1.0.json b/spec/fixtures/expected/python/pipenv/v1.0.json index 6c0ae63..89bce2a 100644 --- a/spec/fixtures/expected/python/pipenv/v1.0.json +++ b/spec/fixtures/expected/python/pipenv/v1.0.json @@ -24,7 +24,7 @@ "url": "http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29" }, "dependency": { - "name": "django", + "name": "Django", "url": "https://www.djangoproject.com/", "description": "A high-level Python Web framework that encourages rapid development and clean, pragmatic design.", "pathes": [ diff --git a/spec/fixtures/expected/python/pipenv/v1.1.json b/spec/fixtures/expected/python/pipenv/v1.1.json index 0528f88..92a5153 100644 --- a/spec/fixtures/expected/python/pipenv/v1.1.json +++ b/spec/fixtures/expected/python/pipenv/v1.1.json @@ -31,7 +31,7 @@ "url": "http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29" }, "dependency": { - "name": "django", + "name": "Django", "url": "https://www.djangoproject.com/", "description": "A high-level Python Web framework that encourages rapid development and clean, pragmatic design.", "pathes": [ diff --git a/spec/fixtures/expected/python/pipenv/v2.0.json b/spec/fixtures/expected/python/pipenv/v2.0.json index bdbeb14..ba4d529 100644 --- a/spec/fixtures/expected/python/pipenv/v2.0.json +++ b/spec/fixtures/expected/python/pipenv/v2.0.json @@ -28,7 +28,7 @@ ], "dependencies": [ { - "name": "django", + "name": "Django", "url": "https://www.djangoproject.com/", "description": "A high-level Python Web framework that encourages rapid development and clean, pragmatic design.", "paths": [ diff --git a/spec/fixtures/python/simple-Pipfile b/spec/fixtures/python/simple-Pipfile new file mode 100644 index 0000000..2a4ffeb --- /dev/null +++ b/spec/fixtures/python/simple-Pipfile @@ -0,0 +1,10 @@ +[[source]] +url = "https://pypi.python.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +requests = "*" + +[dev-packages] +pytest = "*" diff --git a/spec/fixtures/python/simple-Pipfile.lock b/spec/fixtures/python/simple-Pipfile.lock new file mode 100644 index 0000000..655ee42 --- /dev/null +++ b/spec/fixtures/python/simple-Pipfile.lock @@ -0,0 +1,69 @@ +{ + "_meta": { + "hash": { + "sha256": "8d14434df45e0ef884d6c3f6e8048ba72335637a8631cc44792f52fd20b6f97a" + }, + "pipfile-spec": 5, + "requires": {}, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "certifi": { + "hashes": [ + "sha256:54a07c09c586b0e4c619f02a5e94e36619da8e2b053e20f594348c0611803704", + "sha256:40523d2efb60523e113b44602298f0960e900388cf3bb6043f645cf57ea9e3f5" + ], + "version": "==2017.7.27.1" + }, + "chardet": { + "hashes": [ + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691", + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae" + ], + "version": "==3.0.4" + }, + "idna": { + "hashes": [ + "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4", + "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f" + ], + "version": "==2.6" + }, + "requests": { + "hashes": [ + "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", + "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e" + ], + "version": "==2.18.4" + }, + "urllib3": { + "hashes": [ + "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", + "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f" + ], + "version": "==1.22" + } + }, + "develop": { + "py": { + "hashes": [ + "sha256:2ccb79b01769d99115aa600d7eed99f524bf752bba8f041dc1c184853514655a", + "sha256:0f2d585d22050e90c7d293b6451c83db097df77871974d90efd5a30dc12fcde3" + ], + "version": "==1.4.34" + }, + "pytest": { + "hashes": [ + "sha256:b84f554f8ddc23add65c411bf112b2d88e2489fd45f753b1cae5936358bdf314", + "sha256:f46e49e0340a532764991c498244a60e3a37d7424a532b3ff1a6a7653f1a403a" + ], + "version": "==3.2.2" + } + } +} diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index f0aa0db..983ea8b 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -75,23 +75,16 @@ RSpec.describe "pipenv" do expect(report[:version]).not_to be_empty expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to match_array([ - "appdirs", "backports.shutil_get_terminal_size", "click", "colorama", "crayons", "delegator.py", - "packaging", "parse", "pexpect", "ptyprocess", - "py", - "pyparsing", - "pytest", "requests", "requirements-parser", - "setuptools", - "six", "toml" ]) end @@ -146,11 +139,69 @@ RSpec.describe "pipenv" do certifi chardet idna - py - pytest requests urllib3 ]) end end + + context "when fetching metadata from a custom source" do + let(:pipfile_lock_content) do + JSON.pretty_generate({ + "_meta": { + "hash": { "sha256": "" }, + "pipfile-spec": 6, + "requires": { "python_version": "3.8" }, + "sources": [{ "name": "pypi", "url": "https://test.pypi.org/simple", "verify_ssl": true }] + }, + "default": { + "six": { "hashes": [], "index": "pypi", "version": "==1.13.0" } + }, + "develop": {} + }) + end + + before do + runner.add_file('Pipfile.lock', pipfile_lock_content) + end + + it 'produces a valid report' do + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report[:licenses]).not_to be_empty + expect(report[:dependencies].count).to be(1) + expect(find_in(report, 'six')).not_to be_nil + end + end + + context "when scanning a simple Pipfile project" do + let(:lockfile_content) { fixture_file_content('python/simple-Pipfile.lock') } + let(:lockfile_hash) { JSON.parse(lockfile_content) } + + before do + runner.add_file('Pipfile', fixture_file_content('python/simple-Pipfile')) + runner.add_file('Pipfile.lock', lockfile_content) + end + + [2, 3].each do |version| + context "when scanning a Python #{version} project" do + let(:report) { runner.scan(env: { 'LM_PYTHON_VERSION' => version.to_s }) } + + specify { expect(report).to match_schema(version: '2.0') } + + it 'includes dependencies in the default group' do + lockfile_hash['default'].keys.each do |key| + expect(find_in(report, key)).not_to be_nil + end + end + + it 'excludes dependencies in the development group' do + lockfile_hash['develop'].keys.each do |key| + expect(find_in(report, key)).to be_nil + end + end + end + end + end end diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb index 25e670f..de04db3 100644 --- a/spec/support/integration_test_helper.rb +++ b/spec/support/integration_test_helper.rb @@ -34,7 +34,7 @@ module IntegrationTestHelper end def execute(env = {}, *args) - Bundler.with_clean_env do + Bundler.with_unbundled_env do system(env, *args, exception: true) end end |
