Example #1
0
class MoatTest(TestCase):

    def setUp(self):
        self.moat = Moat(MockRepository())

    def test_has(self):
        self.assertTrue(self.moat.has(Permission.read, user, post1))
        self.assertFalse(self.moat.has(Permission.write, user, post1))

    def test_set(self):
        self.assertFalse(self.moat.has(Permission.write, user, post1))
        self.assertTrue(self.moat.set(Permission.write, user, post1))
        self.assertTrue(self.moat.has(Permission.read, user, post1))

    def test_remove(self):
        self.assertTrue(self.moat.has(Permission.read, user, post1))
        self.assertTrue(self.moat.remove(Permission.read, user, post1))
        self.assertFalse(self.moat.remove(Permission.read, user, post1))
        self.assertFalse(self.moat.has(Permission.read, user, post1))

    def test_all(self):
        self.assertEquals(self.moat.all(Permission.read, user, Post), [1, 2])
Example #2
0
 def setUp(self):
     self.moat = Moat(MockRepository())