Skip to content

Commit 76908fc

Browse files
committed
Do not use file for small test data list
Instead inline the data for improved readability Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 557728f commit 76908fc

File tree

8 files changed

+39
-42
lines changed

8 files changed

+39
-42
lines changed

vulntotal/tests/test_data/deps/purls.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

vulntotal/tests/test_data/github/purls.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

vulntotal/tests/test_data/gitlab/purls.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

vulntotal/tests/test_data/osv/purls.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

vulntotal/tests/test_deps.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ class TestDeps(testcase.FileBasedTesting):
2121
test_data_dir = str(Path(__file__).resolve().parent / "test_data" / "deps")
2222

2323
def test_generate_meta_payload(self):
24-
file_purls = self.get_test_loc("purls.txt")
25-
with open(file_purls) as f:
26-
purls = f.readlines()
24+
purls = [
25+
"pkg:pypi/[email protected]",
26+
"pkg:maven/org.apache.tomcat/[email protected]",
27+
"pkg:npm/[email protected]",
28+
"pkg:golang/github.com/cloudflare/[email protected]",
29+
"pkg:cargo/[email protected]",
30+
]
31+
2732
results = [deps.generate_meta_payload(PackageURL.from_string(purl)) for purl in purls]
2833
expected_file = self.get_test_loc("payloads_meta-expected.json", must_exist=False)
2934
util_tests.check_results_against_json(results, expected_file)

vulntotal/tests/test_github.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@ class TestGithub(testcase.FileBasedTesting):
2121
test_data_dir = str(Path(__file__).resolve().parent / "test_data" / "github")
2222

2323
def test_generate_graphql_payload(self):
24-
file_purls = self.get_test_loc("purls.txt")
25-
with open(file_purls) as f:
26-
purls = f.readlines()
24+
purls = [
25+
"pkg:pypi/[email protected]",
26+
"pkg:maven/org.apache.tomcat/[email protected]",
27+
"pkg:nuget/[email protected]",
28+
"pkg:npm/[email protected]",
29+
"pkg:golang/github.com/cloudflare/[email protected]",
30+
"pkg:composer/symfony/[email protected]",
31+
"pkg:rust/[email protected]",
32+
"pkg:erlang/[email protected]",
33+
"pkg:gem/[email protected]",
34+
]
2735
results = [
2836
github.generate_graphql_payload(PackageURL.from_string(purl), "") for purl in purls
2937
]

vulntotal/tests/test_gitlab.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ class TestGitlab(testcase.FileBasedTesting):
2020
test_data_dir = str(Path(__file__).resolve().parent / "test_data" / "gitlab")
2121

2222
def test_generate_package_advisory_url(self):
23-
file_purls = self.get_test_loc("purls.txt")
24-
with open(file_purls) as f:
25-
purls = f.readlines()
23+
purls = [
24+
"pkg:pypi/[email protected]",
25+
"pkg:maven/org.apache.tomcat/[email protected]",
26+
"pkg:npm/[email protected]",
27+
"pkg:golang/github.com/mattermost/mattermost-server/v6/[email protected]",
28+
"pkg:composer/bolt/[email protected]",
29+
"pkg:nuget/[email protected]",
30+
]
2631
results = [gitlab.get_package_slug(PackageURL.from_string(purl)) for purl in purls]
2732
expected_file = self.get_test_loc("package_advisory_url-expected.json", must_exist=False)
2833
util_tests.check_results_against_json(results, expected_file)

vulntotal/tests/test_osv.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ class TestOSV(testcase.FileBasedTesting):
2121
test_data_dir = str(Path(__file__).resolve().parent / "test_data" / "osv")
2222

2323
def test_generate_payload(self):
24-
file_purls = self.get_test_loc("purls.txt")
25-
with open(file_purls) as f:
26-
purls = f.readlines()
24+
purls = [
25+
"pkg:pypi/[email protected]",
26+
"pkg:android/System@10",
27+
"pkg:debian:8/[email protected]",
28+
"pkg:maven/org.apache.tomcat/[email protected]",
29+
"pkg:linux/[email protected]",
30+
"pkg:packagist/dolibarr/[email protected]",
31+
"pkg:crates.io/[email protected]",
32+
"pkg:nuget/[email protected]",
33+
"pkg:npm/[email protected]",
34+
"pkg:golang/github.com/cloudflare/[email protected]",
35+
]
2736
results = [osv.generate_payload(PackageURL.from_string(purl)) for purl in purls]
2837
expected_file = self.get_test_loc("payloads_data-expected.json", must_exist=False)
2938
util_tests.check_results_against_json(results, expected_file)

0 commit comments

Comments
 (0)