def test_no_match_exact(self):
     self.assertFalse(
         match("resource::object::action1", "resource::object::action2"))
     self.assertFalse(
         match("resource::object1::action", "resource::object2::action"))
     self.assertFalse(
         match("resource1::object::action", "resource2::object::action"))
 def test_matching_read(self):
     # This can be done at any level, but will happen most likely at the third
     self.assertTrue(
         match("resource::object::head", "resource::object::read"))
     self.assertTrue(
         match("resource::object::options", "resource::object::read"))
     self.assertTrue(
         match("resource::object::get", "resource::object::read"))
     self.assertTrue(
         match("resource::object::list", "resource::object::read"))
     self.assertTrue(
         match("resource::object::retrieve", "resource::object::read"))
 def test_triad_length(self):
     self.assertEqual(match("", "ok::ok::ok"), None)
     self.assertEqual(match("a", "ok::ok::ok"), None)
     self.assertEqual(match("a::b", "ok::ok::ok"), None)
     self.assertEqual(match("a::b::c::", "ok::ok::ok"), None)
     self.assertEqual(match("a::b::c::d", "ok::ok::ok"), None)
     self.assertEqual(match("ok::ok::ok", "a"), None)
     self.assertEqual(match("ok::ok::ok", "a::b"), None)
     self.assertEqual(match("ok::ok::ok", "a::b::c::"), None)
     self.assertEqual(match("ok::ok::ok", "a::b::c::d"), None)
 def test_matching_some(self):
     # One level
     self.assertTrue(
         match("resource::object::some",
               "resource::object::action",
               strict=False))
     self.assertTrue(
         match("resource::some::action",
               "resource::object::action",
               strict=False))
     self.assertTrue(
         match("some::object::action",
               "resource::object::action",
               strict=False))
     # Two levels
     self.assertTrue(
         match("resource::some::some",
               "resource::object::action",
               strict=False))
     self.assertTrue(
         match("some::some::action",
               "resource::object::action",
               strict=False))
     self.assertTrue(
         match("some::object::some",
               "resource::object::action",
               strict=False))
     # Three levels
     self.assertTrue(
         match("some::some::some", "resource::object::action",
               strict=False))
 def test_matching_write(self):
     # This can be done at any level, but will happen most likely at the third
     self.assertTrue(
         match("resource::object::post", "resource::object::write"))
     self.assertTrue(
         match("resource::object::put", "resource::object::write"))
     self.assertTrue(
         match("resource::object::patch", "resource::object::write"))
     self.assertTrue(
         match("resource::object::delete", "resource::object::write"))
     self.assertTrue(
         match("resource::object::create", "resource::object::write"))
     self.assertTrue(
         match("resource::object::update", "resource::object::write"))
     self.assertTrue(
         match("resource::object::partial-update",
               "resource::object::write"))
     self.assertTrue(
         match("resource::object::destroy", "resource::object::write"))
 def test_no_match_wildcard_levels(self):
     self.assertFalse(
         match("resource::object1::action", "resource::object2::*"))
     self.assertFalse(
         match("resource::object1::action", "resource::object2::*"))
     self.assertFalse(
         match("resource::object::action1", "resource::*::action2"))
     self.assertFalse(
         match("resource::object::action1", "resource::*::action2"))
     self.assertFalse(
         match("resource1::object::action", "resource2::object::*"))
     self.assertFalse(
         match("resource1::object::action", "resource2::object::*"))
 def test_matching_all_or_asterisk(self):
     # One level
     self.assertTrue(
         match("resource::object::action", "resource::object::all"))
     self.assertTrue(
         match("resource::object::action", "resource::object::*"))
     self.assertTrue(
         match("resource::object::action", "resource::all::action"))
     self.assertTrue(
         match("resource::object::action", "resource::*::action"))
     self.assertTrue(
         match("resource::object::action", "all::object::action"))
     self.assertTrue(match("resource::object::action", "*::object::action"))
     # Two levels
     self.assertTrue(match("resource::object::action", "resource::*::all"))
     self.assertTrue(match("resource::object::action", "resource::all::*"))
     self.assertTrue(match("resource::object::action", "*::all::action"))
     self.assertTrue(match("resource::object::action", "all::*::action"))
     self.assertTrue(match("resource::object::action", "all::object::*"))
     self.assertTrue(match("resource::object::action", "*::object::all"))
     # Three levels
     self.assertTrue(match("resource::object::action", "all::*::all"))
     self.assertTrue(match("resource::object::action", "*::all::*"))
 def test_matching_exact(self):
     self.assertTrue(
         match("resource::object::action", "resource::object::action"))