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) )
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') )
def setUp(self): super(SharesTestCase, self).setUp() self.user2 = User.create(dict( username="******", password="******", email="*****@*****.**" )) Share.create_or_update(self.user2, self.default_document)
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"})
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()
def setUp(self): super(SharesTestCase, self).setUp() self.user2 = User.create( dict(username="******", password="******", email="*****@*****.**")) Share.create_or_update(self.user2, self.default_document)
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)
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())
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))
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'))