コード例 #1
0
    def test_one_user_group_write_and_publish(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        g = Group(name='usergroup')
        g.save()
        g.set_users([u.id])

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))

        f.grant('Write', group=g)
        f.grant('Publish', group=g)

        f = Feed.get(id=f.id)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [g])
        self.assertEqual(f.publisher_groups(), [g])

        self.assertTrue(f.user_can_write(u))
        self.assertTrue(f.user_can_publish(u))
コード例 #2
0
    def test_one_user_group_read_only(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        g = Group(name='usergroup')
        g.set_users([u.id])
        g.save()

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))

        f.grant('Read', group=g)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))
コード例 #3
0
    def test_one_user_group_write_and_publish(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        g = Group(name='usergroup')
        g.save()
        g.set_users([u.id])

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))

        f.grant('Write', group=g)
        f.grant('Publish', group=g)

        f = Feed.get(id=f.id)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [g])
        self.assertEqual(f.publisher_groups(), [g])

        self.assertTrue(f.user_can_write(u))
        self.assertTrue(f.user_can_publish(u))
コード例 #4
0
    def test_one_user_group_read_only(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        g = Group(name='usergroup')
        g.set_users([u.id])
        g.save()

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))

        f.grant('Read', group=g)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))
コード例 #5
0
    def test_no_users(self):
        f = Feed(name='123')
        f.save()

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])
コード例 #6
0
    def test_no_users(self):
        f = Feed(name='123')
        f.save()

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])
コード例 #7
0
    def test_one_user_publish(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        f.grant('Publish', user=u)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [u])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertTrue(f.user_can_publish(u))
コード例 #8
0
    def test_one_user_publish(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        f.grant('Publish', user=u)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [u])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertTrue(f.user_can_publish(u))