示例#1
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()
示例#2
0
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()
示例#3
0
 def test_random_int(self):
     random = helpers.random_int(low=1, high=1000)
     self.assertLess(random, 1001)
     self.assertGreater(random, 0)