def test_correct_role_create(self): with self.app() as c: with self.app_context(): role = Role(name="Moderator") role.save_to_db() UserModel("Test", "asdf", [role,]).save_to_db() r = c.post("/auth", headers = {"Content-Type": "application/json"} , data =json.dumps({"username":"******", "password": "******"})) auth_key = "JWT {}".format(json.loads(r.data)["access_token"]) r = c.post("/store/Test", headers={"Authorization" : auth_key}) self.assertEqual(r.status_code, 201) self.assertIsNotNone(StoreModel.find_by_name("Test"))
def setUp(self): super(StoreTest, self).setUp() with self.app() as c: with self.app_context(): role = Role(name="Moderator") role.save_to_db() UserModel("Test", "asdf", [ role, ]).save_to_db() r = c.post("/auth", headers={"Content-Type": "application/json"}, data=json.dumps({ "username": "******", "password": "******" })) self.auth_key = "JWT {}".format( json.loads(r.data)["access_token"])