Example #1
0
    def test_should_give_high_priority_if_matcher_says_so(self):
        link = Link()
        matcher = RequestMatcher(Policy.PRIORITIZE)
        matcher.add_domain_re(r'^.+\.com$')
        link.add_request_matcher(matcher)

        actual = link.get_request_priority_level(Request("google.com", 80))
        self.assertEqual(actual, PriorityLevel.HIGH)
Example #2
0
    def test_should_forbid_request_if_domain_is_not_in_whitelist(self):
        link = Link()
        matcher = RequestMatcher(Policy.ALLOW)
        matcher.add_domain_re(r'^.+\.com$')
        link.add_request_matcher(matcher)

        actual = link.get_request_priority_level(Request("google.fr", 80))
        self.assertEqual(actual, PriorityLevel.FORBID)
Example #3
0
    def test_should_give_normal_priority_if_prioritized_and_deprioritized_at_the_same_time(
            self):
        link = Link()
        matcher = RequestMatcher(Policy.ALLOW)
        matcher.add_domain_re(r'^.+\.com$')
        link.add_request_matcher(matcher)

        matcher = RequestMatcher(Policy.FORBID)
        matcher.add_domain_re(r'^.+\.com$')
        link.add_request_matcher(matcher)

        actual = link.get_request_priority_level(Request("google.com", 80))
        self.assertEqual(actual, PriorityLevel.FORBID)
Example #4
0
    def test_should_give_normal_priority_if_no_matcher_is_given(self):
        link = Link()

        actual = link.get_request_priority_level(Request("google.com", 80))
        self.assertEqual(actual, PriorityLevel.NORMAL)