import unittest import sys sys.path.insert(0, "/www/wwwroot/getDomain/domainCheck") from app.utils.database import _detect_job_item_step_priority from app.utils.database import _ordered_step_claim_codes from app.utils.database import _resolve_step_claim_quota class DetectJobItemClaimPriorityTestCase(unittest.TestCase): def test_ordered_step_claim_codes_prioritize_deeper_steps_first(self): ordered = _ordered_step_claim_codes() self.assertLess(ordered.index("detect_360_site"), ordered.index("detect_baidu_site")) self.assertLess(ordered.index("detect_chinaz"), ordered.index("detect_360_site")) self.assertGreater(ordered.index("detect_register"), ordered.index("detect_baidu_site")) def test_later_pipeline_steps_are_prioritized_ahead_of_earlier_steps(self): self.assertLess( _detect_job_item_step_priority("detect_360_site"), _detect_job_item_step_priority("detect_baidu_site"), ) self.assertLess( _detect_job_item_step_priority("detect_chinaz"), _detect_job_item_step_priority("detect_360_site"), ) self.assertLess( _detect_job_item_step_priority("detect_aizhan"), _detect_job_item_step_priority("detect_chinaz"), ) def test_non_register_steps_are_prioritized_ahead_of_register(self): self.assertLess( _detect_job_item_step_priority("detect_baidu_site"), _detect_job_item_step_priority("detect_register"), ) self.assertLess( _detect_job_item_step_priority("detect_wayback"), _detect_job_item_step_priority("detect_register"), ) def test_blank_step_code_has_lowest_priority(self): self.assertGreater( _detect_job_item_step_priority(""), _detect_job_item_step_priority("detect_register"), ) def test_step_claim_quota_defaults_to_quarter_window_with_floor(self): self.assertEqual(64, _resolve_step_claim_quota(120)) self.assertEqual(300, _resolve_step_claim_quota(1200)) if __name__ == "__main__": unittest.main()