예제 #1
0
    def test_get_share(self):
        with self.assertRaises(ValueError):
            Share.get_share(user=self.default_user)

        self.assertIsNotNone(
            Share.get_share(self.user2, self.default_document)
        )
예제 #2
0
 def test_create_or_update_share(self):
     Share.create_or_update(self.user2, self.default_document)
     Share.create_or_update(
         self.user2, self.default_document, write=True
     )
     self.assertTrue(
         self.default_document.user_has_access(self.user2, 'write')
     )
예제 #3
0
 def setUp(self):
     super(SharesTestCase, self).setUp()
     self.user2 = User.create(dict(
         username="******",
         password="******",
         email="*****@*****.**"
     ))
     Share.create_or_update(self.user2, self.default_document)
예제 #4
0
 def setUp(self):
     super(DocumentModelTestCase, self).setUp()
     self.user2 = User.create({
         "username": "******",
         "email": "*****@*****.**",
         "password": "******",
     })
     Share.create_or_update(self.user2, self.default_document, read=True)
     self.random_doc = Document.create({"title": "random document"})
예제 #5
0
 def setUp(self):
     super(DocumentModelTestCase, self).setUp()
     self.user2 = User.create({
         "username": "******",
         "email": "*****@*****.**",
         "password": "******",
     })
     Share.create_or_update(self.user2, self.default_document, read=True)
     self.random_doc = Document.create({"title": "random document"})
예제 #6
0
def fake_shares(verbose=False):
    users = User.query.all()
    docs = Document.query.all()
    length = len(docs)
    for count, user in enumerate(users, 1):
        for _ in range(random_int(high=10)):
            doc = docs[random_int(high=length-1)]
            if doc not in user.documents.all():
                Share.create_or_update(user, doc, True, True, commit=False)
        if verbose:
            print "Shares for users %s/%s" % (count, len(users))
    db.session.commit()
예제 #7
0
 def setUp(self):
     super(SharesTestCase, self).setUp()
     self.user2 = User.create(
         dict(username="******", password="******", email="*****@*****.**"))
     Share.create_or_update(self.user2, self.default_document)
예제 #8
0
    def test_shares_for_user(self):
        readable = Share.shares_for_user(user=self.user2, read=True)
        self.assertGreater(len(readable), 0)

        writable = Share.shares_for_user(user=self.user2, write=True)
        self.assertEqual(len(writable), 0)
예제 #9
0
 def test_shares_for_user_query(self):
     query = Share.shares_for_user_query(user=self.user2)
     self.assertIsNotNone(query.all())
     self.assertIsNone(Share.shares_for_user_query())
예제 #10
0
    def test_get_share(self):
        with self.assertRaises(ValueError):
            Share.get_share(user=self.default_user)

        self.assertIsNotNone(Share.get_share(self.user2,
                                             self.default_document))
예제 #11
0
 def test_create_or_update_share(self):
     Share.create_or_update(self.user2, self.default_document)
     Share.create_or_update(self.user2, self.default_document, write=True)
     self.assertTrue(
         self.default_document.user_has_access(self.user2, 'write'))
예제 #12
0
    def test_shares_for_user(self):
        readable = Share.shares_for_user(user=self.user2, read=True)
        self.assertGreater(len(readable), 0)

        writable = Share.shares_for_user(user=self.user2, write=True)
        self.assertEqual(len(writable), 0)
예제 #13
0
 def test_shares_for_user_query(self):
     query = Share.shares_for_user_query(user=self.user2)
     self.assertIsNotNone(query.all())
     self.assertIsNone(Share.shares_for_user_query())