Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
homework36 committed Nov 1, 2024
1 parent e0a9c2a commit a3b4d4c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rodan-main/code/rodan/jobs/resource_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ def my_error_information(self, exc, traceback):
def test_my_task(self, testcase):
import PIL.Image
import numpy as np
resource_types_list = list(map(lambda rt: str(rt.mimetype), ResourceType.objects.all()))
from model_mommy import mommy
from rodan.models import Resource, ResourceType
resource_types_list = list(map(lambda rt: str(rt.mimetype), ResourceType.objects.all()))
from model_mommy import mommy

# Create a Resource instance using mommy
resource_type = mommy.make(ResourceType, mimetype="image/rgb+png")
rc = mommy.make(Resource, resource_type=resource_type)
resource_type, created = ResourceType.objects.get_or_create(mimetype="image/rgb+png")
rc = mommy.make(Resource, resource_type=resource_type, name="test_filename")

inputs = {
"Resource input": [
{
"resource_path": rc.resource_path,
"resource_path": testcase.new_available_path(),
"resource_type": rc.resource_type.mimetype,
"resource": rc
}
Expand Down Expand Up @@ -223,5 +223,6 @@ def test_my_task(self, testcase):
# and the data should be identical
np.testing.assert_equal(array_gt, array_result)

# Test name change
new_name = f"{settings['User custom prefix']}{original_image}{settings['User custom suffix']}"
testcase.assertEqual(inputs['Resource input'][0]['resource'].name, new_name)

0 comments on commit a3b4d4c

Please sign in to comment.