forked from gemfileparser/gemfileparser
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gemfileparser.py
More file actions
70 lines (44 loc) · 1.65 KB
/
Copy pathtest_gemfileparser.py
File metadata and controls
70 lines (44 loc) · 1.65 KB
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
#!/usr/bin/env python
#
# Copyright (c) Balasankar C <[email protected]> and others
# SPDX-License-Identifier: GPL-3.0-or-later OR MIT
from gemfileparser import GemfileParser
def check_gemparser_results(test_file, regen=False):
"""
Run GemfileParser.parse on `test_file` and check against a JSON file that
contains expected results with the same name as the `test_file` with a
"-expected.json" suffix appended.
"""
import json
gemparser = GemfileParser(test_file)
dependencies = {
group: [dep.to_dict() for dep in deps]
for group, deps in gemparser.parse().items()
}
expected_file = test_file + '-expected.json'
if regen:
with open(expected_file, 'w') as o:
json.dump(dependencies, o, indent=2)
with open(expected_file) as o:
expected = json.load(o)
assert expected == dependencies
def test_source_only_gemfile():
check_gemparser_results('tests/Gemfile')
def test_gemfile_1():
check_gemparser_results('tests/Gemfile_1')
def test_gemfile_2():
check_gemparser_results('tests/Gemfile_2')
def test_gemfile_3():
check_gemparser_results('tests/Gemfile_3')
def test_gemfile_4():
check_gemparser_results('tests/Gemfile_4')
def test_gemfile_platforms():
check_gemparser_results('tests/Gemfile_5')
def test_gemspec_1():
check_gemparser_results('tests/sample.gemspec')
def test_gemspec_2():
check_gemparser_results('tests/address_standardization.gemspec')
def test_gemspec_3():
check_gemparser_results('tests/arel.gemspec')
def test_gemspec_4():
check_gemparser_results('tests/logstash-mixin-ecs_compatibility_support.gemspec')