From 38a2f3123bb4dc6ec2f7479a0e682c92b81a954b Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 20 Mar 2020 17:08:23 -0600 Subject: Install pip packages from a custom index * Read PIP_INDEX_URL to identify where to download packages from --- spec/integration/python/pip_spec.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'spec/integration/python') diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index 9c565a9..e54aa19 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -65,4 +65,37 @@ RSpec.describe "pip" do end end end + + context "when scanning projects with a `setup.py` but do not have a `requirements.txt` files" do + pending 'detects licenses in a simple `setup.py`' do + runner.add_file('setup.py', fixture_file_content('python/simple-setup.py')) + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report[:dependencies]).not_to be_empty + expect(find_in(report, 'boto3')[:licenses]).to match_array(['MIT']) + end + + pending 'detects licenses in a more complicated `setup.py`' do + runner.add_file('setup.py', fixture_file_content('python/complex-setup.py')) + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report[:dependencies]).not_to be_empty + expect(find_in(report, 'peppercorn')[:licenses]).to match_array(['BSD-2-Clause']) + end + end + + context "when scanning projects that have a custom index-url" do + before do + runner.add_file('requirements.txt', 'pip==18.1') + end + + it 'detects the licenses from the custom index' do + report = runner.scan(env: { 'PIP_INDEX_URL' => 'https://test.pypi.org/simple/' }) + + expect(report).to match_schema(version: '2.0') + expect(find_in(report, 'pip')[:licenses]).to match_array(["MIT"]) + end + end end -- cgit v1.2.3