[PATCH] changeset_status unit tests: simplify

Thomas De Schampheleire patrickdepinguin at gmail.com
Sat Apr 25 16:22:59 EDT 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1429991908 -7200
#      Sat Apr 25 21:58:28 2015 +0200
# Node ID 8ee97fa4482e406c7441c1f07b794d29eb089d12
# Parent  7f62f8ef3acc8ce197156d138936a56329f0d151
changeset_status unit tests: simplify

diff --git a/kallithea/tests/models/test_changeset_status.py b/kallithea/tests/models/test_changeset_status.py
--- a/kallithea/tests/models/test_changeset_status.py
+++ b/kallithea/tests/models/test_changeset_status.py
@@ -1,47 +1,39 @@
 from kallithea.tests import *
 from kallithea.model.changeset_status import ChangesetStatusModel
-from kallithea.model.db import ChangesetStatus
+from kallithea.model.db import ChangesetStatus as CS
 
-# shorthands
-STATUS_APPROVED = ChangesetStatus.STATUS_APPROVED
-STATUS_REJECTED = ChangesetStatus.STATUS_REJECTED
-STATUS_NOT_REVIEWED = ChangesetStatus.STATUS_NOT_REVIEWED
-STATUS_UNDER_REVIEW = ChangesetStatus.STATUS_UNDER_REVIEW
-
-class ChangesetStatusMock(object):
+class CSM(object): # ChangesetStatusMock
 
     def __init__(self, status):
         self.status = status
 
-S = ChangesetStatusMock
-
 class TestChangesetStatusCalculation(BaseTestCase):
 
     def setUp(self):
         self.m = ChangesetStatusModel()
 
     @parameterized.expand([
-        ('empty list', STATUS_UNDER_REVIEW, []),
-        ('approve', STATUS_APPROVED, [S(STATUS_APPROVED)]),
-        ('approve2', STATUS_APPROVED, [S(STATUS_APPROVED), S(STATUS_APPROVED)]),
-        ('approve_reject', STATUS_REJECTED, [S(STATUS_APPROVED), S(STATUS_REJECTED)]),
-        ('approve_underreview', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_UNDER_REVIEW)]),
-        ('approve_notreviewed', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_NOT_REVIEWED)]),
-        ('underreview', STATUS_UNDER_REVIEW, [S(STATUS_UNDER_REVIEW), S(STATUS_UNDER_REVIEW)]),
-        ('reject', STATUS_REJECTED, [S(STATUS_REJECTED)]),
-        ('reject_underreview', STATUS_REJECTED, [S(STATUS_REJECTED), S(STATUS_UNDER_REVIEW)]),
-        ('reject_notreviewed', STATUS_REJECTED, [S(STATUS_REJECTED), S(STATUS_NOT_REVIEWED)]),
-        ('notreviewed', STATUS_UNDER_REVIEW, [S(STATUS_NOT_REVIEWED)]),
-        ('approve_none', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), None]),
-        ('approve2_none', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_APPROVED), None]),
-        ('approve_reject_none', STATUS_REJECTED, [S(STATUS_APPROVED), S(STATUS_REJECTED), None]),
-        ('approve_underreview_none', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_UNDER_REVIEW), None]),
-        ('approve_notreviewed_none', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_NOT_REVIEWED), None]),
-        ('underreview_none', STATUS_UNDER_REVIEW, [S(STATUS_UNDER_REVIEW), S(STATUS_UNDER_REVIEW), None]),
-        ('reject_none', STATUS_REJECTED, [S(STATUS_REJECTED), None]),
-        ('reject_underreview_none', STATUS_REJECTED, [S(STATUS_REJECTED), S(STATUS_UNDER_REVIEW), None]),
-        ('reject_notreviewed_none', STATUS_REJECTED, [S(STATUS_REJECTED), S(STATUS_NOT_REVIEWED), None]),
-        ('notreviewed_none', STATUS_UNDER_REVIEW, [S(STATUS_NOT_REVIEWED), None]),
+        ('empty list', CS.STATUS_UNDER_REVIEW, []),
+        ('approve', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED)]),
+        ('approve2', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_APPROVED)]),
+        ('approve_reject', CS.STATUS_REJECTED, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_REJECTED)]),
+        ('approve_underreview', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_UNDER_REVIEW)]),
+        ('approve_notreviewed', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_NOT_REVIEWED)]),
+        ('underreview', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_UNDER_REVIEW), CSM(CS.STATUS_UNDER_REVIEW)]),
+        ('reject', CS.STATUS_REJECTED, [CSM(CS.STATUS_REJECTED)]),
+        ('reject_underreview', CS.STATUS_REJECTED, [CSM(CS.STATUS_REJECTED), CSM(CS.STATUS_UNDER_REVIEW)]),
+        ('reject_notreviewed', CS.STATUS_REJECTED, [CSM(CS.STATUS_REJECTED), CSM(CS.STATUS_NOT_REVIEWED)]),
+        ('notreviewed', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_NOT_REVIEWED)]),
+        ('approve_none', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_APPROVED), None]),
+        ('approve2_none', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_APPROVED), None]),
+        ('approve_reject_none', CS.STATUS_REJECTED, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_REJECTED), None]),
+        ('approve_underreview_none', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_UNDER_REVIEW), None]),
+        ('approve_notreviewed_none', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_NOT_REVIEWED), None]),
+        ('underreview_none', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_UNDER_REVIEW), CSM(CS.STATUS_UNDER_REVIEW), None]),
+        ('reject_none', CS.STATUS_REJECTED, [CSM(CS.STATUS_REJECTED), None]),
+        ('reject_underreview_none', CS.STATUS_REJECTED, [CSM(CS.STATUS_REJECTED), CSM(CS.STATUS_UNDER_REVIEW), None]),
+        ('reject_notreviewed_none', CS.STATUS_REJECTED, [CSM(CS.STATUS_REJECTED), CSM(CS.STATUS_NOT_REVIEWED), None]),
+        ('notreviewed_none', CS.STATUS_UNDER_REVIEW, [CSM(CS.STATUS_NOT_REVIEWED), None]),
     ])
     def test_result(self, name, expected_result, statuses):
         result = self.m._calculate_status(statuses)


More information about the kallithea-general mailing list