Skip to content

Commit

Permalink
Add unit test for the archived scancode-config.yml behavior #1236
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed May 21, 2024
1 parent e99d26b commit 61d18a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Binary file not shown.
25 changes: 24 additions & 1 deletion scanpipe/tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@


class ScanPipePipelinesTest(TestCase):
data_location = Path(__file__).parent / "data"

def test_scanpipe_pipeline_class_pipeline_name_attribute(self):
project1 = Project.objects.create(name="Analysis")
run = project1.add_pipeline("do_nothing")
Expand Down Expand Up @@ -159,7 +161,7 @@ def test_scanpipe_pipeline_class_download_missing_inputs(self, mock_get):
run = project1.add_pipeline("do_nothing")
pipeline = run.make_pipeline_instance()

file_location = Path(__file__).parent / "data" / "notice.NOTICE"
file_location = self.data_location / "notice.NOTICE"
input_source = project1.add_input_source(
filename=file_location.name, is_uploaded=True
)
Expand Down Expand Up @@ -302,6 +304,27 @@ def test_scanpipe_pipelines_class_env_loaded_from_config_file(self):
pipeline = run.make_pipeline_instance()
self.assertEqual({"product_name": "Product"}, pipeline.env)

def test_scanpipe_pipelines_class_env_reloaded_after_extraction(self):
project1 = Project.objects.create(name="Analysis")

input_location = self.data_location / "settings/archived-scancode-config.zip"
project1.copy_input_from(input_location)
run = project1.add_pipeline("scan_codebase")
pipeline = run.make_pipeline_instance()
self.assertEqual({}, pipeline.env)

# Manually run steps, env is reload from the scancode-config.yml contained in
# the archive
pipeline.copy_inputs_to_codebase_directory()
pipeline.extract_archives()

expected = {
"product_name": "My Product Name",
"product_version": "1.0",
"ignored_patterns": ["*.tmp", "tests/*"],
}
self.assertEqual(expected, pipeline.env)

def test_scanpipe_pipelines_class_flag_ignored_resources(self):
project1 = Project.objects.create(name="Analysis")
run = project1.add_pipeline("do_nothing")
Expand Down

0 comments on commit 61d18a0

Please sign in to comment.