summaryrefslogtreecommitdiff
path: root/spec/integration/python/pipenv_spec.rb
blob: 2756f6b5a1bef7f7a5e6c7ac2b4783d0c98ced9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'spec_helper'

RSpec.describe "pipenv" do
  context "when a project depends on a version 6 Pipfile.lock" 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://pypi.org/simple", "verify_ssl": true } ]
        },
        "default": {
          "six": { "hashes": [], "index": "pypi", "version": "==1.13.0" }
        },
        "develop": {}
      })
    end

    it 'produces a valid report' do
      runner.add_file('Pipfile.lock', pipfile_lock_content)

      report = runner.scan

      expect(report).not_to be_empty
      expect(report).to match_schema(version: '2.0')
      expect(report[:version]).not_to be_empty
      expect(report[:licenses]).not_to be_empty
      expect(report[:dependencies].map { |x| x[:name] }).to include("six")
    end
  end

  context "when a project depends on a version 3.2.1 Pipfile.lock" do
    let(:pipfile_lock_content) do
      JSON.pretty_generate({
        "default": {
          "crayons": { "version": "==0.1.2", "hash": "" },
          "requirements-parser": { "version": "==0.1.0", "hash": "" },
          "pexpect": { "version": "==4.2.1", "hash": "" },
          "delegator.py": { "version": "==0.0.8", "hash": "" },
          "backports.shutil_get_terminal_size": { "version": "==1.0.0", "hash": "" },
          "ptyprocess": { "version": "==0.5.1", "hash": "" },
          "parse": { "version": "==1.6.6", "hash": "" },
          "toml": { "version": "==0.9.2", "hash": "" },
          "colorama": { "version": "==0.3.7", "hash": "" },
          "requests": { "version": "==2.13.0", "hash": "" },
          "click": { "version": "==6.7", "hash": "" }
        },
        "develop": {
          "packaging": { "version": "==16.8", "hash": "" },
          "pytest": { "version": "==3.0.6", "hash": "" },
          "setuptools": { "version": "==34.0.2", "hash": "" },
          "pyparsing": { "version": "==2.1.10", "hash": "" },
          "py": { "version": "==1.4.32", "hash": "" },
          "six": { "version": "==1.10.0", "hash": "" },
          "appdirs": { "version": "==1.4.0", "hash": "" }
        },
        "_meta": {
          "sources": [ { "url": "https://pypi.python.org/simple", "verify_ssl": true } ],
          "requires": {},
          "Pipfile-sha256": "24f12b631b7c40b8c5eff934a1aef263ed04f5eaffb4acf4706442f3d23cba36"
        }
      })
    end

    it 'produces a valid report' do
      runner.add_file('Pipfile.lock', pipfile_lock_content)

      report = runner.scan

      expect(report).to match_schema(version: '2.0')
      expect(report).not_to be_empty
      expect(report[:version]).not_to be_empty
      expect(report[:licenses]).not_to be_empty
      expect(report[:dependencies].count).to eql(18)
    end
  end
end