def test_allow_correct_defaults_to_all(self): """ Tests that if we don't pass anything as an allow directives, it defaults to "all". """ handle_location = Location(**{"location": self.valid_location}) self.assertEqual(handle_location.allow, ["all"]) handle_location.allow = None self.assertEqual(handle_location.allow, ["all"]) del handle_location
def test_allow_correct_no_dupes(self): """ Tests that if among the allow directives passed in "all" is not present, only a unique copy of each allow directive is stored. """ allow_directives = ["1.2.3.4"] handle_location = Location(**{"location": self.valid_location}) handle_location.allow = allow_directives * 5 self.assertEqual(handle_location.allow, ["1.2.3.4"]) del handle_location
def test_allow_correct_all_rules_any_other_rule_out(self): """ Tests that if any of the allow directives is "all" then all other allow directives are not considered at all. """ allow_directives = ["1.2.3.4", "1.2.3.5/24", "all", "2.2.2.2"] handle_location = Location(**{"location": self.valid_location}) handle_location.allow = allow_directives self.assertEqual(handle_location.allow, ["all"]) del handle_location
def test_allow_correct(self): """ Tests that if we pass in a valid set of directives, allow is properly updated to that value. """ for valid_allow_directive in self.valid_allow_directives: handle_location = Location(**{"location": self.valid_location}) handle_location.allow = valid_allow_directive self.assertEqual(handle_location.allow, valid_allow_directive) del handle_location
def test_allow_correct_defaults_to_all(self): """ Tests that if we don't pass anything as an allow directives, it defaults to "all". """ handle_location = Location(**{ "location" : self.valid_location } ) self.assertEqual(handle_location.allow, ["all"]) handle_location.allow = None self.assertEqual(handle_location.allow, ["all"]) del handle_location
def test_allow_correct_no_dupes(self): """ Tests that if among the allow directives passed in "all" is not present, only a unique copy of each allow directive is stored. """ allow_directives = ["1.2.3.4"] handle_location = Location(**{ "location" : self.valid_location } ) handle_location.allow = allow_directives * 5 self.assertEqual(handle_location.allow, ["1.2.3.4"]) del handle_location
def test_allow_correct_all_rules_any_other_rule_out(self): """ Tests that if any of the allow directives is "all" then all other allow directives are not considered at all. """ allow_directives = ["1.2.3.4", "1.2.3.5/24", "all", "2.2.2.2"] handle_location = Location(**{ "location" : self.valid_location } ) handle_location.allow = allow_directives self.assertEqual(handle_location.allow, ["all"]) del handle_location
def test_allow_correct(self): """ Tests that if we pass in a valid set of directives, allow is properly updated to that value. """ for valid_allow_directive in self.valid_allow_directives: handle_location = Location(**{ "location" : self.valid_location } ) handle_location.allow = valid_allow_directive self.assertEqual(handle_location.allow, valid_allow_directive) del handle_location