Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Priyadarshi <[email protected]>
  • Loading branch information
keshav-space committed Aug 26, 2024
1 parent 7246d8f commit 1364361
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
7 changes: 4 additions & 3 deletions vulnerabilities/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from vulnerabilities.importer import AdvisoryData
from vulnerabilities.improver import MAX_CONFIDENCE
from vulnerabilities.models import Advisory
from vulnerabilities.pipes import advisory
from vulnerabilities.pipes.advisory import import_advisory
from vulnerabilities.pipes.advisory import insert_advisory
from vulnerabilities.utils import classproperty

module_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -85,7 +86,7 @@ def collect_and_store_advisories(self):
collected_advisory_count = 0
progress = LoopProgress(total_iterations=self.advisories_count(), logger=self.log)
for advisory in progress.iter(self.collect_advisories()):
if _obj := advisory.insert_advisory(
if _obj := insert_advisory(
advisory=advisory,
pipeline_name=self.qualified_name,
logger=self.log,
Expand Down Expand Up @@ -115,7 +116,7 @@ def import_new_advisories(self):

def import_advisory(self, advisory: Advisory) -> int:
try:
advisory.import_advisory(
import_advisory(
advisory=advisory,
pipeline_name=self.qualified_name,
confidence=self.advisory_confidence,
Expand Down
19 changes: 10 additions & 9 deletions vulnerabilities/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
)


advisory1 = models.Advisory(
aliases=advisory_data1.aliases,
summary=advisory_data1.summary,
affected_packages=[pkg.to_dict() for pkg in advisory_data1.affected_packages],
references=[ref.to_dict() for ref in advisory_data1.references],
url=advisory_data1.url,
created_by="tests",
date_collected=timezone.now(),
)
def get_advisory1(created_by="test_pipeline"):
return models.Advisory.objects.create(
aliases=advisory_data1.aliases,
summary=advisory_data1.summary,
affected_packages=[pkg.to_dict() for pkg in advisory_data1.affected_packages],
references=[ref.to_dict() for ref in advisory_data1.references],
url=advisory_data1.url,
created_by=created_by,
date_collected=timezone.now(),
)


def get_all_vulnerability_relationships_objects():
Expand Down
4 changes: 2 additions & 2 deletions vulnerabilities/tests/pipelines/test_base_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

from vulnerabilities import models
from vulnerabilities.pipelines import VulnerableCodeBaseImporterPipeline
from vulnerabilities.tests import advisory1
from vulnerabilities.tests import advisory_data1
from vulnerabilities.tests import get_advisory1


class TestVulnerableCodeBaseImporterPipeline(TestCase):
Expand Down Expand Up @@ -50,7 +50,7 @@ def test_import_new_advisories(self):
self.assertEqual(0, models.Vulnerability.objects.count())

base_pipeline = VulnerableCodeBaseImporterPipeline()
base_pipeline.new_advisories = [advisory1]
advisory1 = get_advisory1(created_by=base_pipeline.qualified_name)
base_pipeline.import_new_advisories()

self.assertEqual(1, models.Vulnerability.objects.count())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pytest

from vulnerabilities.pipes.importer import import_advisory
from vulnerabilities.pipes.advisory import import_advisory
from vulnerabilities.tests import advisory1
from vulnerabilities.tests import get_all_vulnerability_relationships_objects

Expand Down

0 comments on commit 1364361

Please sign in to comment.