annotate kallithea/tests/models/test_changeset_status.py @ 8687:5e46f73f0d1c

model: always import the whole db module - drop "from" imports
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 12 Oct 2020 11:12:37 +0200
parents e527cc2ce8dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
1 from kallithea.model import db
5039
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
2 from kallithea.model.changeset_status import ChangesetStatusModel
8109
e527cc2ce8dc cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents: 7811
diff changeset
3 from kallithea.tests import base
5039
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
4
6864
7691290837d2 codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents: 6217
diff changeset
5
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
6 STATUS_UNDER_REVIEW = db.ChangesetStatus.STATUS_UNDER_REVIEW
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
7 STATUS_APPROVED = db.ChangesetStatus.STATUS_APPROVED
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
8 STATUS_REJECTED = db.ChangesetStatus.STATUS_REJECTED
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
9 STATUS_NOT_REVIEWED = db.ChangesetStatus.STATUS_NOT_REVIEWED
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
10
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
11
5067
481a484b1d69 tests: simplify changeset_status unit tests
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5047
diff changeset
12 class CSM(object): # ChangesetStatusMock
5039
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
13
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
14 def __init__(self, status):
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
15 self.status = status
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
16
6864
7691290837d2 codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents: 6217
diff changeset
17
8109
e527cc2ce8dc cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents: 7811
diff changeset
18 class TestChangesetStatusCalculation(base.TestController):
5039
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
19
5805
be1d20bfd2dd pytest migration: model: convert all tests to TestControllerPytest
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5067
diff changeset
20 def setup_method(self, method):
5039
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
21 self.m = ChangesetStatusModel()
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
22
8109
e527cc2ce8dc cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents: 7811
diff changeset
23 @base.parametrize('name,expected_result,statuses', [
8687
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
24 ('empty list', STATUS_UNDER_REVIEW, []),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
25 ('approve', STATUS_APPROVED, [CSM(STATUS_APPROVED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
26 ('approve2', STATUS_APPROVED, [CSM(STATUS_APPROVED), CSM(STATUS_APPROVED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
27 ('approve_reject', STATUS_REJECTED, [CSM(STATUS_APPROVED), CSM(STATUS_REJECTED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
28 ('approve_underreview', STATUS_UNDER_REVIEW, [CSM(STATUS_APPROVED), CSM(STATUS_UNDER_REVIEW)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
29 ('approve_notreviewed', STATUS_UNDER_REVIEW, [CSM(STATUS_APPROVED), CSM(STATUS_NOT_REVIEWED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
30 ('underreview', STATUS_UNDER_REVIEW, [CSM(STATUS_UNDER_REVIEW), CSM(STATUS_UNDER_REVIEW)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
31 ('reject', STATUS_REJECTED, [CSM(STATUS_REJECTED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
32 ('reject_underreview', STATUS_REJECTED, [CSM(STATUS_REJECTED), CSM(STATUS_UNDER_REVIEW)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
33 ('reject_notreviewed', STATUS_REJECTED, [CSM(STATUS_REJECTED), CSM(STATUS_NOT_REVIEWED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
34 ('notreviewed', STATUS_UNDER_REVIEW, [CSM(STATUS_NOT_REVIEWED)]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
35 ('approve_none', STATUS_UNDER_REVIEW, [CSM(STATUS_APPROVED), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
36 ('approve2_none', STATUS_UNDER_REVIEW, [CSM(STATUS_APPROVED), CSM(STATUS_APPROVED), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
37 ('approve_reject_none', STATUS_REJECTED, [CSM(STATUS_APPROVED), CSM(STATUS_REJECTED), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
38 ('approve_underreview_none', STATUS_UNDER_REVIEW, [CSM(STATUS_APPROVED), CSM(STATUS_UNDER_REVIEW), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
39 ('approve_notreviewed_none', STATUS_UNDER_REVIEW, [CSM(STATUS_APPROVED), CSM(STATUS_NOT_REVIEWED), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
40 ('underreview_none', STATUS_UNDER_REVIEW, [CSM(STATUS_UNDER_REVIEW), CSM(STATUS_UNDER_REVIEW), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
41 ('reject_none', STATUS_REJECTED, [CSM(STATUS_REJECTED), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
42 ('reject_underreview_none', STATUS_REJECTED, [CSM(STATUS_REJECTED), CSM(STATUS_UNDER_REVIEW), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
43 ('reject_notreviewed_none', STATUS_REJECTED, [CSM(STATUS_REJECTED), CSM(STATUS_NOT_REVIEWED), None]),
5e46f73f0d1c model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents: 8109
diff changeset
44 ('notreviewed_none', STATUS_UNDER_REVIEW, [CSM(STATUS_NOT_REVIEWED), None]),
5039
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
45 ])
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
46 def test_result(self, name, expected_result, statuses):
36d81185efe4 changeset_status: add unit tests for calculation of overall status
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
diff changeset
47 result = self.m._calculate_status(statuses)
5912
7483b3f3bea5 pytest migration: models: switch to standard assert statements
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5805
diff changeset
48 assert result == expected_result