Ejemplo n.º 1
0
    def test_role_get(self):
        with self.client:
            # registered user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # get role
            res_get_role = get_all_role(self, data['access_token'])
            data_get_role = json.loads(res_get_role.data.decode())
            self.assertTrue(res_get_role.status_code == 200)
Ejemplo n.º 2
0
    def test_role_delete(self):
        with self.client:
            # registered user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # delete role
            res_delete_role = delete_role(self, data['access_token'])
            data_delete_role = json.loads(res_delete_role.data.decode())
            self.assertEqual(res_delete_role.status_code, 200)
            self.assertTrue(data_delete_role['status'] == 'success')
Ejemplo n.º 3
0
 def test_get_messages_should_return_not_found(self):
     register_user(self)
     login_response = login_user(self)
     headers = dict(
         Authorization=json.loads(login_response.data)['Authorization'])
     payload = json.dumps(dict(name='trip', picture_path='picture/path'))
     create_trip_response = \
         self.client.post('/trip/', headers=headers, data=payload, content_type='application/json')
     trip_id = json.loads(create_trip_response.data)['id']
     user_id = json.loads(login_response.data)['id']
     save_message(get_chat_message_object("message", trip_id, user_id))
     get_messages_response = self.client.get('/chat_message/{}'.format(
         str(2)),
                                             headers=headers)
     self.assertEqual(get_messages_response.status_code, 404)
Ejemplo n.º 4
0
    def test_role_create_already(self):
        with self.client:
            # registered user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # create conflict
            create_role(self, data['access_token'])
            res_create_role_conflict = create_role(self, data['access_token'])
            data_create_role = json.loads(
                res_create_role_conflict.data.decode())
            self.assertTrue(data_create_role['status'] == 'fail')
            self.assertEqual(res_create_role_conflict.status_code, 409)
Ejemplo n.º 5
0
    def test_role_update(self):
        with self.client:
            # registered user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # update role
            res_update_role = update_role(self, data['access_token'])
            data_update_role = json.loads(res_update_role.data.decode())
            self.assertTrue(data_update_role['status'] == 'success')
            self.assertTrue(data_update_role['name'] == 'ROLE_USER')
            self.assertTrue(data_update_role['description'] == 'Done')
            self.assertEqual(res_update_role.status_code, 200)
    def test_permission_update(self):
        with self.client:
            # user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # update permission
            res_update_permission = update_permission(self,
                                                      data['access_token'])
            data_update_permission = json.loads(
                res_update_permission.data.decode())
            self.assertTrue(data_update_permission['status'] == 'success')
            self.assertTrue(
                data_update_permission['name'] == 'CREATE_PERMISSION')
            self.assertTrue(data_update_permission['description'] == 'Done')
            self.assertEqual(res_update_permission.status_code, 200)
    def test_permission_get(self):
        with self.client:
            # registered user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # create permission
            res_create_permission = create_permission(self,
                                                      data['access_token'])
            data_create_permission = json.loads(
                res_create_permission.data.decode())
            self.assertTrue(data_create_permission['status'] == 'success')
            self.assertEqual(res_create_permission.status_code, 201)

            # delete permission
            res_get_permission = get_all_permission(self, data['access_token'])
            data_get_permission = json.loads(res_get_permission.data.decode())
            self.assertTrue(res_get_permission.status_code == 200)
Ejemplo n.º 8
0
    def test_role_set(self):
        with self.client:
            # registered user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # get info me
            res_info = Auth.get_info_me(self, data['access_token'])
            data_info_me = json.loads(res_info.data.decode())
            self.assertTrue(data_info_me['username'] == 'admin')
            self.assertTrue(res_info.content_type == 'application/json')
            self.assertEqual(res_info.status_code, 200)

            res_set_role = set_role(self, data['access_token'],
                                    data_info_me['public_id'])
            data_set_role = json.loads(res_set_role.data.decode())
            self.assertTrue(res_set_role.content_type == 'application/json')
            self.assertEqual(res_set_role.status_code, 201)
    def test_permission_create(self):
        # user registration
        resp_register = Auth.register_user(self)
        data_register = json.loads(resp_register.data.decode())
        self.assertTrue(data_register['status'] == 'success')
        self.assertTrue(data_register['message'] == 'Successfully registered.')
        self.assertTrue(resp_register.content_type == 'application/json')
        self.assertEqual(resp_register.status_code, 201)
        # registered user login
        response = Auth.login_user(self)
        data = json.loads(response.data.decode())
        self.assertTrue(response.content_type == 'application/json')
        self.assertEqual(response.status_code, 200)

        # create permission
        res_create_permission = create_permission(self, data['access_token'])
        data_create_permission = json.loads(
            res_create_permission.data.decode())
        self.assertTrue(data_create_permission['status'] == 'success')
        self.assertTrue(
            res_create_permission.content_type == 'application/json')
        self.assertEqual(res_create_permission.status_code, 201)
    def test_permission_get_list_by_id(self):
        with self.client:
            # user login
            response = Auth.login_user(self)
            data = json.loads(response.data.decode())
            self.assertTrue(response.content_type == 'application/json')
            self.assertEqual(response.status_code, 200)

            # get info me
            res_info = Auth.get_info_me(self, data['access_token'])
            data_info_me = json.loads(res_info.data.decode())
            self.assertTrue(data_info_me['username'] == 'admin')
            self.assertTrue(res_info.content_type == 'application/json')
            self.assertEqual(res_info.status_code, 200)

            # update permission
            res_list_permission_id = get_permission_by_id(
                self, data['access_token'], data_info_me['public_id'])
            data_list_permission = json.loads(
                res_list_permission_id.data.decode())
            self.assertTrue(data_list_permission['status'] == 'success')
            self.assertEqual(res_list_permission_id.status_code, 200)