Skip to content

Commit

Permalink
Add unit test test_scanpipe_pipes_make_relationship #688
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Apr 24, 2023
1 parent 1dab3e2 commit 7976ce7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scanpipe/tests/pipes/test_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from django.test import TransactionTestCase

from scanpipe import pipes
from scanpipe.models import CodebaseRelation
from scanpipe.models import CodebaseResource
from scanpipe.models import DiscoveredPackage
from scanpipe.models import Project
Expand Down Expand Up @@ -137,6 +138,25 @@ def test_scanpipe_pipes_update_or_create_dependency(self):
dependency = pipes.update_or_create_dependency(p1, dependency_data)
self.assertEqual(dependency.scope, "install")

def test_scanpipe_pipes_make_relationship(self):
p1 = Project.objects.create(name="Analysis")
from_resource = CodebaseResource.objects.create(project=p1, path="Name.java")
to_resource = CodebaseResource.objects.create(project=p1, path="Name.class")

relation = pipes.make_relationship(
from_resource=from_resource,
to_resource=to_resource,
relationship=CodebaseRelation.Relationship.COMPILED,
match_type="java_to_class",
extra_data={"extra": "data"},
)

self.assertEqual(from_resource, relation.from_resource)
self.assertEqual(to_resource, relation.to_resource)
self.assertEqual(CodebaseRelation.Relationship.COMPILED, relation.relationship)
self.assertEqual("java_to_class", relation.match_type)
self.assertEqual({"extra": "data"}, relation.extra_data)


class ScanPipePipesTransactionTest(TransactionTestCase):
"""
Expand Down

0 comments on commit 7976ce7

Please # to comment.