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)]
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) ]
def create_tag(): user = api.helpers.get_user() data = tag_schema.load(request.get_json()).data data["user"] = user tag = Tag.create(data) xhr = MakeResponse(201, tag.to_dict()) return xhr.response
def test_delete_tag_no_access(self): tag = Tag.create(dict(title="TAGGY")) res = self.client.delete('/tags/%s' % tag.id, headers=self.headers) self.assertStatus(res, 401) self.assertIsNotNone(Tag.query.get(tag.id))
def test_get_tag_no_access(self): tag = Tag.create(dict(title="TAGGY")) res = self.client.get("/tags/%s" % tag.id, headers=self.headers) self.assertStatus(res, 401)