diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-08-15 16:22:21 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2018-08-15 16:22:21 +0800 |
commit | afebd41fb7f90a7c70d95a64d0ca7c2560897f72 (patch) | |
tree | 3b881195b4e56969c2197481aeb0a2de245f2d9b | |
parent | 79dcd9221c739f6457887177d3c088319797eb6e (diff) |
Add unit test for jobutil
Change-Id: I4a218645096627bf5fe6d65a22fb2e2629d77b21
Issue-ID: VFC-1009
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/pub/utils/tests.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lcm/pub/utils/tests.py b/lcm/pub/utils/tests.py index 36184720..5bc836c8 100644 --- a/lcm/pub/utils/tests.py +++ b/lcm/pub/utils/tests.py @@ -157,3 +157,47 @@ class UtilsTest(unittest.TestCase): self.assertEqual(1, len(JobStatusModel.objects.filter(jobid=job_id))) JobStatusModel.objects.filter().delete() JobModel.objects.filter().delete() + + def test_clear_job_status(self): + job_id = "1" + JobStatusModel.objects.filter().delete() + JobStatusModel( + indexid=1, + jobid=job_id, + status="success", + progress=10 + ).save() + JobUtil.clear_job_status(job_id) + self.assertEqual(0, len(JobStatusModel.objects.filter(jobid=job_id))) + + def test_get_unfinished_jobs(self): + JobModel.objects.filter().delete() + JobModel( + jobid="11", + jobtype="InstVnf", + jobaction="2", + resid="3", + status=0 + ).save() + JobModel( + jobid="22", + jobtype="InstVnf", + jobaction="2", + resid="3", + status=0 + ).save() + JobModel( + jobid="33", + jobtype="InstVnf", + jobaction="2", + resid="3", + status=0 + ).save() + progresses = JobUtil.get_unfinished_jobs( + url_prefix="/vnfinst", + inst_id="3", + inst_type="InstVnf" + ) + expect_progresses = ['/vnfinst/11', '/vnfinst/22', '/vnfinst/33'] + self.assertEqual(expect_progresses, progresses) + JobModel.objects.filter().delete() |