-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backfill resolved_on and needs_work_started_on. (#4678)
* Backfill resolved_on and needs_work_started_on. * mypy-fix * Registered a URL for the new script. * Don't set fields if they were already set. * mypy-fix
- Loading branch information
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -757,3 +757,104 @@ def test_calc_all_shipping_years__some(self, mock_gasswm: mock.MagicMock): | |
actual = self.handler.calc_all_shipping_years() | ||
expected = {22222: 2023, 33333: 2024, 44444: 2030} | ||
self.assertEqual(expected, actual) | ||
|
||
|
||
class BackfillGateDatesTest(testing_config.CustomTestCase): | ||
|
||
def setUp(self): | ||
self.gate = Gate( | ||
feature_id=1, stage_id=2, | ||
gate_type=core_enums.GATE_API_EXTEND_ORIGIN_TRIAL, | ||
state=Gate.PREPARING) | ||
self.handler = maintenance_scripts.BackfillGateDates() | ||
|
||
def test_calc_resolved_on__not_resolved(self): | ||
"""If a gate is not resolved, don't set a resolved_on date.""" | ||
self.assertIsNone( | ||
self.handler.calc_resolved_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.REVIEW_REQUESTED | ||
self.assertIsNone( | ||
self.handler.calc_resolved_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.NA_REQUESTED | ||
self.assertIsNone( | ||
self.handler.calc_resolved_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.REVIEW_STARTED | ||
self.assertIsNone( | ||
self.handler.calc_resolved_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.NEEDS_WORK | ||
self.assertIsNone( | ||
self.handler.calc_resolved_on(self.gate, [])) | ||
|
||
def test_calc_resolved_on__resolved(self): | ||
"""If a gate was resolved, resolved_on is the last approval.""" | ||
self.gate.state = Vote.APPROVED | ||
gate_id = 1234 | ||
v1 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.REVIEW_REQUESTED, | ||
set_on=datetime(2023, 1, 1, 12, 30, 0)) | ||
v2 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.REVIEW_STARTED, | ||
set_on=datetime(2023, 1, 2, 12, 30, 0)) | ||
v3 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.APPROVED, | ||
set_on=datetime(2023, 1, 3, 12, 30, 0)) | ||
v4 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.APPROVED, | ||
set_on=datetime(2023, 1, 4, 12, 30, 0)) | ||
v5 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.REVIEW_STARTED, | ||
set_on=datetime(2023, 1, 5, 12, 30, 0)) | ||
|
||
self.assertEqual( | ||
self.handler.calc_resolved_on(self.gate, [v1, v2, v3, v4, v5]), | ||
v4.set_on) | ||
|
||
def test_calc_needs_work_started_on__not_needed(self): | ||
"""If a gate is not NEEDS_WORK, don't set a needs_work_started_on date.""" | ||
self.assertIsNone( | ||
self.handler.calc_needs_work_started_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.REVIEW_REQUESTED | ||
self.assertIsNone( | ||
self.handler.calc_needs_work_started_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.NA_REQUESTED | ||
self.assertIsNone( | ||
self.handler.calc_needs_work_started_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.REVIEW_STARTED | ||
self.assertIsNone( | ||
self.handler.calc_needs_work_started_on(self.gate, [])) | ||
|
||
self.gate.state = Vote.APPROVED | ||
self.assertIsNone( | ||
self.handler.calc_needs_work_started_on(self.gate, [])) | ||
|
||
def test_calc_needs_work_started_on__needed(self): | ||
"""If a gate is NEEDS_WORK, it started on the last NEEDS_WORK vote.""" | ||
self.gate.state = Vote.NEEDS_WORK | ||
gate_id = 1234 | ||
v1 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.REVIEW_REQUESTED, | ||
set_on=datetime(2023, 1, 1, 12, 30, 0)) | ||
v2 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.NEEDS_WORK, | ||
set_on=datetime(2023, 1, 2, 12, 30, 0)) | ||
v3 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.APPROVED, | ||
set_on=datetime(2023, 1, 3, 12, 30, 0)) | ||
v4 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.NEEDS_WORK, | ||
set_on=datetime(2023, 1, 4, 12, 30, 0)) | ||
v5 = Vote(gate_id=gate_id, set_by='[email protected]', | ||
state=Vote.REVIEW_STARTED, | ||
set_on=datetime(2023, 1, 5, 12, 30, 0)) | ||
|
||
self.assertEqual( | ||
self.handler.calc_needs_work_started_on( | ||
self.gate, [v1, v2, v3, v4, v5]), | ||
v4.set_on) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters