From a3b4d4cacbed73646620ea036dcda551badf1c72 Mon Sep 17 00:00:00 2001 From: Hanwen Zh <70364944+homework36@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:24:21 -0400 Subject: [PATCH] fix unit test --- rodan-main/code/rodan/jobs/resource_distributor.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rodan-main/code/rodan/jobs/resource_distributor.py b/rodan-main/code/rodan/jobs/resource_distributor.py index cbfe6016..8ff69773 100644 --- a/rodan-main/code/rodan/jobs/resource_distributor.py +++ b/rodan-main/code/rodan/jobs/resource_distributor.py @@ -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 } @@ -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) \ No newline at end of file