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 fake_documents(verbose=False): users = User.query.all() for count, user in enumerate(users, 1): for doc in range(random_int(high=50)): try: user.documents.append(DocumentFactory()) except Exception as e: print e if verbose: print "Documents for users %s/%s" % (count, len(users)) db.session.commit()
def test_random_int(self): random = helpers.random_int(low=1, high=1000) self.assertLess(random, 1001) self.assertGreater(random, 0)