示例#1
0
 def test_create(self):
     User.create({
         "username": "******",
         "email": "*****@*****.**",
         "password": "******"
     })
     db.session.flush()
     db.session.expire_all()
     get = User.query.filter_by(username="******").first()
     self.assertIsNotNone(get)
     self.assertEqual(get.email, "*****@*****.**")
示例#2
0
 def test_create(self):
     User.create({
         "username": "******",
         "email": "*****@*****.**",
         "password": "******"
     })
     db.session.flush()
     db.session.expire_all()
     get = User.query.filter_by(username="******").first()
     self.assertIsNotNone(get)
     self.assertEqual(get.email, "*****@*****.**")
示例#3
0
    def setUp(self):
        super(BaseTestCase, self).setUp()
        self.app = create_app(config.Testing)
        self.app_context = self.app.app_context()
        self.client = self.app.test_client()
        self.app_context.push()
        self.db = db
        self.db.drop_all()
        self.db.create_all()
        self.user = dict(
            username="******",
            password="******",
            first_name="Test",
            last_name="User",
            _admin=True
        )
        self.document = dict(
            title="This is a Test Title",
            body="Body Body Body, likeasomebody"
        )
        self.tag = {"title": "TAGGY"}

        self.default_user = User.create(self.user)
        self.default_document = Document.create(self.document)
        self.default_document.user = self.default_user
        self.tag = Tag.create(self.tag)
        self.tag.user = self.default_user
        self.default_document.tags.append(self.tag)
        self.db.session.commit()
        self.redis_store = RedisStore(store=FakeStrictRedis, name='test')
        token = jwt.create_token_for_user(self.default_user)
        self.headers = [
            ('Content-Type', 'application/json'),
            ('Authorization', 'Bearer %s' % token)
        ]
示例#4
0
    def setUp(self):
        super(BaseTestCase, self).setUp()
        self.app = create_app(config.Testing)
        self.app_context = self.app.app_context()
        self.client = self.app.test_client()
        self.app_context.push()
        self.db = db
        self.db.drop_all()
        self.db.create_all()
        self.user = dict(username="******",
                         password="******",
                         first_name="Test",
                         last_name="User",
                         _admin=True)
        self.document = dict(title="This is a Test Title",
                             body="Body Body Body, likeasomebody")
        self.tag = {"title": "TAGGY"}

        self.default_user = User.create(self.user)
        self.default_document = Document.create(self.document)
        self.default_document.user = self.default_user
        self.tag = Tag.create(self.tag)
        self.tag.user = self.default_user
        self.default_document.tags.append(self.tag)
        self.db.session.commit()
        self.redis_store = RedisStore(store=FakeStrictRedis, name='test')
        token = jwt.create_token_for_user(self.default_user)
        self.headers = [('Content-Type', 'application/json'),
                        ('Authorization', 'Bearer %s' % token)]
示例#5
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)
示例#6
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"})
示例#7
0
 def test_filter_by_access(self):
     user = User.create(
         dict(username='******', password='******', email='*****@*****.**'))
     Document.create(dict(title="title", body="d", user=user))
     available = filter_by_access(
         user,
         Document.query.all(),
     )
     self.assertEqual(len(available), 1)
示例#8
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"})
示例#9
0
 def test_filter_by_access(self):
     user = User.create(dict(
         username='******',
         password='******',
         email='*****@*****.**'
     ))
     Document.create(dict(title="title", body="d", user=user))
     available = filter_by_access(
         user,
         Document.query.all(),
     )
     self.assertEqual(len(available), 1)
示例#10
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)