def test_deny_correct_defaults_to_all(self): """ Tests that if we don't pass anything as a deny directives, it defaults to an empty list. """ handle_location = Location(**{"location": self.valid_location}) self.assertEqual(handle_location.deny, []) handle_location.deny = None self.assertEqual(handle_location.deny, []) del handle_location
def test_deny_correct_no_dupes(self): """ Tests that if among the deny directives passed in "all" is not present, only a unique copy of each deny directive is stored. """ deny_directives = ["1.2.3.4"] handle_location = Location(**{"location": self.valid_location}) handle_location.deny = deny_directives * 5 self.assertEqual(handle_location.deny, ["1.2.3.4"]) del handle_location
def test_deny_correct_all_rules_any_other_rule_out(self): """ Tests that if any of the deny directives is "all" then all other deny directives are not considered at all. """ deny_directives = ["1.2.3.4", "1.2.3.5/24", "all", "2.2.2.2"] handle_location = Location(**{"location": self.valid_location}) handle_location.deny = deny_directives self.assertEqual(handle_location.deny, ["all"]) del handle_location
def test_deny_correct(self): """ Tests that if we pass in a valid set of directives, deny is properly updated to that value. """ for valid_deny_directive in self.valid_deny_directives: handle_location = Location(**{"location": self.valid_location}) handle_location.deny = valid_deny_directive self.assertEqual(handle_location.deny, valid_deny_directive) del handle_location
def test_deny_correct_defaults_to_all(self): """ Tests that if we don't pass anything as a deny directives, it defaults to an empty list. """ handle_location = Location(**{ "location" : self.valid_location } ) self.assertEqual(handle_location.deny, []) handle_location.deny = None self.assertEqual(handle_location.deny, []) del handle_location
def test_deny_correct_no_dupes(self): """ Tests that if among the deny directives passed in "all" is not present, only a unique copy of each deny directive is stored. """ deny_directives = ["1.2.3.4"] handle_location = Location(**{ "location" : self.valid_location } ) handle_location.deny = deny_directives * 5 self.assertEqual(handle_location.deny, ["1.2.3.4"]) del handle_location
def test_deny_correct_all_rules_any_other_rule_out(self): """ Tests that if any of the deny directives is "all" then all other deny directives are not considered at all. """ deny_directives = ["1.2.3.4", "1.2.3.5/24", "all", "2.2.2.2"] handle_location = Location(**{ "location" : self.valid_location } ) handle_location.deny = deny_directives self.assertEqual(handle_location.deny, ["all"]) del handle_location
def test_deny_correct(self): """ Tests that if we pass in a valid set of directives, deny is properly updated to that value. """ for valid_deny_directive in self.valid_deny_directives: handle_location = Location(**{ "location" : self.valid_location } ) handle_location.deny = valid_deny_directive self.assertEqual(handle_location.deny, valid_deny_directive) del handle_location