Пример #1
0
 def test_admin_get(self):
     json_res, dict_res = get(self.client(), "admin")
     self.assertEqual(json_res.status_code, 404)
     post(self.client(), "admin", json_dict=self.data)
     json_res, dict_res = get(self.client(), "admin")
     self.assertEqual(json_res.status_code, 200)
     self.assertEqual(dict_res['email'], self.data['email'])
Пример #2
0
 def test_login(self):
     post(self.client(), "admin", json_dict=self.data)
     json_res, dict_res = post(self.client(),
                               "login",
                               json_dict=self.auth_data)
     self.assertEqual(json_res.status_code, 200)
     self.assertEqual(dict_res['isAdmin'], True)
Пример #3
0
 def test_companies_get(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_post(self.client(), "companies",
                                    company_data, token)
     json_res, dict_res = auth_get(self.client(), "companies", token)
     self.assertEqual(json_res.status_code, 200)
Пример #4
0
 def test_single_admin_get(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_get(self.client(),
                                   "admin/{}".format(auth_data['admin_id']),
                                   token=token)
     self.assertEqual(json_res.status_code, 200)
 def test_employee_create(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_post(self.client(), "employees",
                                    employee_data, token)
     self.assertEqual(json_res.status_code, 201)
     self.assertEqual(dict_res["username"], employee_data["username"])
Пример #6
0
 def test_single_admin_update(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     put_data = {"firstname": "updated_name", "lastname": "woohoo"}
     u = "admin/{}".format(auth_data['admin_id'])
     json_res, dict_res = auth_put(self.client(), u, put_data, token)
     self.assertEqual(json_res.status_code, 200)
     self.assertEqual(dict_res["firstname"], put_data["firstname"])
     self.assertEqual(dict_res["lastname"], put_data["lastname"])
Пример #7
0
 def test_company_delete(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_post(self.client(), "companies",
                                    company_data, token)
     id = dict_res["id"]
     json_res, dict_res = auth_del(self.client(), "company/{}".format(id),
                                   token)
     self.assertEqual(json_res.status_code, 200)
     self.assertEqual(dict_res["name"], company_data["name"])
Пример #8
0
 def test_company_create(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_post(self.client(), "companies",
                                    company_data, token)
     self.assertEqual(json_res.status_code, 201)
     self.assertEqual(dict_res["name"], company_data["name"])
     json_res, dict_res = auth_post(self.client(), "companies",
                                    company_data, token)
     self.assertEqual(json_res.status_code, 409)
     self.assertEqual(dict_res["message"], "Company already exists.")
Пример #9
0
 def test_company_update(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_post(self.client(), "companies",
                                    company_data, token)
     id = dict_res["id"]
     update_data = {"description": "simple company1"}
     json_res, dict_res = auth_put(self.client(), "company/{}".format(id),
                                   update_data, token)
     self.assertEqual(json_res.status_code, 200)
     self.assertEqual(dict_res["description"], "simple company1")
 def test_employee_update(self):
     # create the admin
     post(self.client(), "admin", json_dict=self.data)
     # receive the login token
     token, auth_data = get_auth_token(self.client(), self.auth_data)
     json_res, dict_res = auth_post(self.client(), "employees",
                                    employee_data, token)
     id = dict_res["employee_id"]
     update_data = {"firstname": "updated name"}
     json_res, dict_res = auth_put(self.client(), "employee/{}".format(id),
                                   update_data, token)
     self.assertEqual(json_res.status_code, 201)
     self.assertEqual(dict_res["firstname"], update_data["firstname"])
Пример #11
0
 def test_admin_creation(self):
     json_res, dict_res = post(self.client(), "admin", json_dict=self.data)
     self.assertEqual(json_res.status_code, 201)
     self.assertEqual(dict_res["message"],
                      "Successfully created super admin.")