Exemplo n.º 1
0
    def test_users_unknown_delete(self):
        users = Employee.objects.all()
        for user in users:
            response = self.client.delete(APIUrl.users_id(user.id))

            self.assertEqual(response.status_code,
                             status.HTTP_401_UNAUTHORIZED)
Exemplo n.º 2
0
    def test_users_unknown_delete(self):
        users = Employee.objects.all()
        for user in users:
            response = self.client.delete(APIUrl.users_id(user.id))

            self.assertEqual(response.status_code,
                             status.HTTP_401_UNAUTHORIZED)
Exemplo n.º 3
0
    def test_users_user_delete(self):
        self.login_user()
        users = Employee.objects.all()
        for user in users:
            response = self.client.delete(APIUrl.users_id(user.id))

            self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Exemplo n.º 4
0
    def test_users_user_delete(self):
        self.login_user()
        users = Employee.objects.all()
        for user in users:
            response = self.client.delete(APIUrl.users_id(user.id))

            self.assertEqual(response.status_code,
                             status.HTTP_404_NOT_FOUND)
Exemplo n.º 5
0
    def test_users_user_retrieve_self(self):
        login_user = self.login_user()
        response = self.client.get(APIUrl.users_id(login_user.id))

        data = {key: login_user.__getattribute__(key)
                for key in response.data.keys()}

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, data)
Exemplo n.º 6
0
    def test_users_user_retrieve_other(self):
        login_user = self.login_user()
        users = Employee.objects.all()
        for user in users:
            if user.id == login_user.id:
                continue

            response = self.client.get(APIUrl.users_id(user.id))

            self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Exemplo n.º 7
0
    def test_users_user_retrieve_self(self):
        login_user = self.login_user()
        response = self.client.get(APIUrl.users_id(login_user.id))

        data = {
            key: login_user.__getattribute__(key)
            for key in response.data.keys()
        }

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, data)
Exemplo n.º 8
0
    def test_users_user_retrieve_other(self):
        login_user = self.login_user()
        users = Employee.objects.all()
        for user in users:
            if user.id == login_user.id:
                continue

            response = self.client.get(APIUrl.users_id(user.id))

            self.assertEqual(response.status_code,
                             status.HTTP_404_NOT_FOUND)
Exemplo n.º 9
0
    def test_users_user_update_self(self):
        login_user = self.login_user()
        response = self.client.put(APIUrl.users_id(login_user.id), {
            'username': '******',
            'password': '******',
            'email': '*****@*****.**',
            'rang': 'some',
            'group_code': '2'
        })

        self.assertEqual(response.data['group_code'], login_user.group_code)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 10
0
    def test_users_user_update_self(self):
        login_user = self.login_user()
        response = self.client.put(
            APIUrl.users_id(login_user.id), {
                'username': '******',
                'password': '******',
                'email': '*****@*****.**',
                'rang': 'some',
                'group_code': '2'
            })

        self.assertEqual(response.data['group_code'], login_user.group_code)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 11
0
    def test_users_unknown_update(self):
        users = Employee.objects.all()
        for user in users:
            response = self.client.put(APIUrl.users_id(user.id), {
                'username': '******',
                'password': '******',
                'email': '*****@*****.**',
                'rang': 'some',
                'group_code': '2'
            })

            self.assertEqual(response.status_code,
                             status.HTTP_401_UNAUTHORIZED)
Exemplo n.º 12
0
    def test_users_unknown_update(self):
        users = Employee.objects.all()
        for user in users:
            response = self.client.put(
                APIUrl.users_id(user.id), {
                    'username': '******',
                    'password': '******',
                    'email': '*****@*****.**',
                    'rang': 'some',
                    'group_code': '2'
                })

            self.assertEqual(response.status_code,
                             status.HTTP_401_UNAUTHORIZED)
Exemplo n.º 13
0
    def test_users_user_update_other(self):
        login_user = self.login_user()
        users = Employee.objects.all()
        for user in users:
            if user.id == login_user.id:
                continue

            response = self.client.put(
                APIUrl.users_id(user.id), {
                    'username': '******',
                    'password': '******',
                    'email': '*****@*****.**',
                    'rang': 'some',
                    'group_code': '2'
                })

            self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Exemplo n.º 14
0
    def test_users_user_update_other(self):
        login_user = self.login_user()
        users = Employee.objects.all()
        for user in users:
            if user.id == login_user.id:
                continue

            response = self.client.put(APIUrl.users_id(user.id), {
                'username': '******',
                'password': '******',
                'email': '*****@*****.**',
                'rang': 'some',
                'group_code': '2'
            })

            self.assertEqual(response.status_code,
                             status.HTTP_404_NOT_FOUND)