From 787139543acf5544b48cc942c0917ba683962ce2 Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 24 Jan 2024 10:08:15 -0500 Subject: [PATCH] chore: use setters; removes deprecation warnings --- .../lib/scheduler/dmod/test/test_JobImpl.py | 20 +++++++++---------- .../lib/scheduler/dmod/test/test_scheduler.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/lib/scheduler/dmod/test/test_JobImpl.py b/python/lib/scheduler/dmod/test/test_JobImpl.py index 22d8f0c26..dd5f45e15 100644 --- a/python/lib/scheduler/dmod/test/test_JobImpl.py +++ b/python/lib/scheduler/dmod/test/test_JobImpl.py @@ -55,7 +55,7 @@ def test_job_id_1_a(self): self.assertNotEqual(job.job_id, uuid_as_str) - job.job_id = uuid_val + job.set_job_id(uuid_val) self.assertEqual(job.job_id, uuid_as_str) @@ -68,7 +68,7 @@ def test_job_id_1_b(self): job = self._example_jobs[example_index] initial_last_updated = job.last_updated - job.job_id = uuid_val + job.set_job_id(uuid_val) self.assertLess(initial_last_updated, job.last_updated) @@ -81,7 +81,7 @@ def test_job_id_1_c(self): self.assertNotEqual(job.job_id, uuid_as_str) - job.job_id = uuid_as_str + job.set_job_id(uuid_as_str) self.assertEqual(job.job_id, uuid_as_str) @@ -93,7 +93,7 @@ def test_job_id_1_d(self): job = self._example_jobs[example_index] initial_last_updated = job.last_updated - job.job_id = uuid_as_str + job.set_job_id(uuid_as_str) self.assertLess(initial_last_updated, job.last_updated) @@ -142,7 +142,7 @@ def test_allocations_1_a(self): job = self._example_jobs[example_index_job] self.assertIsNone(job.allocations) - job.allocations = allocations + job.set_allocations(allocations) self.assertIsNotNone(job.allocations) # Test that allocation setter works with tuple @@ -155,7 +155,7 @@ def test_allocations_1_b(self): job = self._example_jobs[example_index_job] self.assertIsNone(job.allocations) - job.allocations = allocations + job.set_allocations(allocations) self.assertIsNotNone(job.allocations) # Test that allocation setter works correctly with list @@ -166,7 +166,7 @@ def test_allocations_1_c(self): allocation = self._resource_allocations[example_index_allocation] allocations = [allocation] job = self._example_jobs[example_index_job] - job.allocations = allocations + job.set_allocations(allocations) self.assertEqual(len(allocations), len(job.allocations)) for i in range(len(allocations)): self.assertEqual(allocations[i], job.allocations[i]) @@ -179,7 +179,7 @@ def test_allocations_1_d(self): allocation = self._resource_allocations[example_index_allocation] allocations = (allocation,) job = self._example_jobs[example_index_job] - job.allocations = allocations + job.set_allocations(allocations) self.assertEqual(len(allocations), len(job.allocations)) for i in range(len(allocations)): self.assertEqual(allocations[i], job.allocations[i]) @@ -193,7 +193,7 @@ def test_allocations_1_e(self): allocations = [allocation] job = self._example_jobs[example_index_job] initial_last_updated = job.last_updated - job.allocations = allocations + job.set_allocations(allocations) self.assertLess(initial_last_updated, job.last_updated) # Test that allocation setter updates last_updated correctly with tuple @@ -206,7 +206,7 @@ def test_allocations_1_f(self): job = self._example_jobs[example_index_job] initial_last_updated = job.last_updated - job.allocations = allocations + job.set_allocations(allocations) self.assertLess(initial_last_updated, job.last_updated) # TODO: add tests for rest of setters that should update last_updated property diff --git a/python/lib/scheduler/dmod/test/test_scheduler.py b/python/lib/scheduler/dmod/test/test_scheduler.py index 28dbbfbbb..1e4700320 100644 --- a/python/lib/scheduler/dmod/test/test_scheduler.py +++ b/python/lib/scheduler/dmod/test/test_scheduler.py @@ -68,7 +68,7 @@ def setUp(self) -> None: allocation_paradigm='SINGLE_NODE') ex_job = RequestedJob(sch_req) alloc = ResourceAllocation('1', 'hostname1', cpu_count, mem_size) - ex_job.allocations = [alloc] + ex_job.set_allocations([alloc]) self._example_jobs.append(ex_job) # Example 2 - with two node allocated with 4 cpus @@ -96,7 +96,7 @@ def setUp(self) -> None: allocs = [] allocs.append(ResourceAllocation('1', 'hostname1', 2, int(mem_size/2))) allocs.append(ResourceAllocation('2', 'hostname2', 2, int(mem_size/2))) - ex_job.allocations = allocs + ex_job.set_allocations(allocs) self._example_jobs.append(ex_job)