summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-08-14 15:51:29 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-08-14 16:00:17 +0800
commit63a969df1fdf9ccd895769cd9b297b85705b8947 (patch)
tree7927bb1773d30fac0476d4d5e2a767b743c43a77
parent68d6f7f81784780aff58f096870bf8ab53f9963e (diff)
Add unit test for jobutil
Change-Id: I3c63ae508eec95f7471a53f0d961816a9bb49341 Issue-ID: VFC-1009 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/pub/utils/tests.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/lcm/pub/utils/tests.py b/lcm/pub/utils/tests.py
index 706b28bd..232acf05 100644
--- a/lcm/pub/utils/tests.py
+++ b/lcm/pub/utils/tests.py
@@ -18,6 +18,9 @@ import enumutil
import fileutil
import urllib2
+from lcm.pub.database.models import JobStatusModel
+from lcm.pub.utils.jobutil import JobUtil
+
class MockReq():
def read(self):
@@ -53,3 +56,32 @@ class UtilsTest(unittest.TestCase):
self.assertTrue(is_ok)
self.assertTrue(f_name.endswith("abc/1.txt"))
fileutil.delete_dirs("abc")
+
+ def test_query_job_status(self):
+ job_id = "1"
+ JobStatusModel.objects.filter().delete()
+ JobStatusModel(
+ indexid=1,
+ jobid=job_id,
+ status="success",
+ progress=10
+ ).save()
+ JobStatusModel(
+ indexid=2,
+ jobid=job_id,
+ status="success",
+ progress=50
+ ).save()
+ JobStatusModel(
+ indexid=3,
+ jobid=job_id,
+ status="success",
+ progress=100
+ ).save()
+ jobs = JobUtil.query_job_status(job_id)
+ self.assertEqual(1, len(jobs))
+ self.assertEqual(3, jobs[0].indexid)
+ jobs = JobUtil.query_job_status(job_id, 1)
+ self.assertEqual(2, len(jobs))
+ self.assertEqual(3, jobs[0].indexid)
+ self.assertEqual(2, jobs[1].indexid)