summaryrefslogtreecommitdiff
path: root/spec/integration/python
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration/python')
-rw-r--r--spec/integration/python/pip_spec.rb14
-rw-r--r--spec/integration/python/pipenv_spec.rb87
2 files changed, 64 insertions, 37 deletions
diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb
index a52b992..9c2721d 100644
--- a/spec/integration/python/pip_spec.rb
+++ b/spec/integration/python/pip_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
RSpec.describe "pip" do
@@ -100,10 +102,20 @@ RSpec.describe "pip" do
context "when a project uses a custom `SETUP_CMD`" do
before do
runner.add_file('requirements.txt', 'six==1.14.0')
+ runner.add_file('.python-version', '3.8.4')
+ runner.add_file('custom.sh') do
+ <<~SCRIPT
+ #!/bin/bash -lx
+
+ asdf install python 3.8.4
+ asdf reshim
+ pip install -r requirements.txt
+ SCRIPT
+ end
end
it 'detects the software licenses' do
- report = runner.scan(env: { 'SETUP_CMD' => 'pip install -r requirements.txt' })
+ report = runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' })
expect(report).to match_schema(version: '2.0')
expect(report.licenses_for('six')).to match_array(["MIT"])
diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb
index 5cc9128..cd20522 100644
--- a/spec/integration/python/pipenv_spec.rb
+++ b/spec/integration/python/pipenv_spec.rb
@@ -1,6 +1,12 @@
+# frozen_string_literal: true
+
require 'spec_helper'
RSpec.describe "pipenv" do
+ subject { runner.scan(env: env) }
+
+ let(:env) { {} }
+
include_examples "each report version", "python", "pipenv", "pip-file-lock"
context "when a project depends on a version 6 Pipfile.lock" do
@@ -19,15 +25,15 @@ RSpec.describe "pipenv" do
})
end
- it 'produces a valid report' do
+ before do
runner.add_file('Pipfile.lock', pipfile_lock_content)
+ end
- report = runner.scan
-
- expect(report).to match_schema
- expect(report[:version]).not_to be_empty
- expect(report[:licenses]).not_to be_empty
- expect(report.dependency_names).to contain_exactly("six")
+ it 'produces a valid report' do
+ expect(subject).to match_schema
+ expect(subject[:version]).not_to be_empty
+ expect(subject[:licenses]).not_to be_empty
+ expect(subject.dependency_names).to contain_exactly("six")
end
end
@@ -64,15 +70,15 @@ RSpec.describe "pipenv" do
})
end
- it 'produces a valid report' do
+ before do
runner.add_file('Pipfile.lock', pipfile_lock_content)
+ end
- report = runner.scan
-
- expect(report).to match_schema
- expect(report[:version]).not_to be_empty
- expect(report[:licenses]).not_to be_empty
- expect(report.dependency_names).to match_array([
+ it 'produces a valid report' do
+ expect(subject).to match_schema
+ expect(subject[:version]).not_to be_empty
+ expect(subject[:licenses]).not_to be_empty
+ expect(subject.dependency_names).to match_array([
"backports.shutil_get_terminal_size",
"click",
"colorama",
@@ -124,15 +130,15 @@ RSpec.describe "pipenv" do
})
end
- it 'produces a valid report' do
+ before do
runner.add_file('Pipfile.lock', pipfile_lock_content)
+ end
- report = runner.scan
-
- expect(report).to match_schema
- expect(report[:version]).not_to be_empty
- expect(report[:licenses]).not_to be_empty
- expect(report.dependency_names).to match_array(%w[
+ it 'produces a valid report' do
+ expect(subject).to match_schema
+ expect(subject[:version]).not_to be_empty
+ expect(subject[:licenses]).not_to be_empty
+ expect(subject.dependency_names).to match_array(%w[
certifi
chardet
idna
@@ -163,22 +169,19 @@ RSpec.describe "pipenv" do
end
it 'produces a valid report' do
- report = runner.scan
-
- expect(report).to match_schema
- expect(report[:licenses]).not_to be_empty
- expect(report[:dependencies].count).to be(1)
- expect(report.find('six')).not_to be_nil
+ expect(subject).to match_schema
+ expect(subject[:licenses]).not_to be_empty
+ expect(subject[:dependencies].count).to be(1)
+ expect(subject.find('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_content) { fixture_file_content('python/pipenv/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)
+ runner.mount(dir: fixture_file('python/pipenv/simple'))
end
[2, 3].each do |version|
@@ -204,6 +207,12 @@ RSpec.describe "pipenv" do
context "when connecting to a private package repository with self signed certificate" do
let(:index_url) { "https://pypi.test/simple" }
+ let(:env) do
+ {
+ 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate('wildcard.test').read,
+ 'PIP_INDEX_URL' => index_url
+ }
+ end
before do
add_host('pypi.test', '127.0.0.1')
@@ -214,13 +223,19 @@ RSpec.describe "pipenv" do
end
it 'downloads the packages and trusts the certificate' do
- report = runner.scan(env: {
- 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate('wildcard.test').read,
- 'PIP_INDEX_URL' => index_url
- })
+ expect(subject).to match_schema
+ expect(subject.dependency_names).to include('requests')
+ end
+ end
+
+ context "when scanning a project that declares a specific version of python in the lockfile" do
+ before do
+ runner.mount(dir: fixture_file('python/pipenv/specific-python-version'))
+ end
- expect(report).to match_schema
- expect(report.dependency_names).to include('requests')
+ specify do
+ expect(subject).to match_schema
+ expect(subject.dependency_names).to match_array(%w[Django docutils pytz requests])
end
end
end