Exemplo n.º 1
0
    def test_login_required(self):
        base.base_authentication(self)
        response = self.client.post(
            '/api/v1.0/bucketlists/',
            data=json.dumps(dict(
                name="new bucketlist",
            ))
        )

        data = json.loads(response.data.decode())
        self.assertEqual(data['message'], 'Unauthorized Access!')
Exemplo n.º 2
0
    def test_get_bucketlist_by_id(self):
        user_token = base.base_authentication(self)
        base.base_add_bucketlist(self)

        response = self.client.get(
            '/api/v1.0/bucketlists/1/',
            headers={'Authorization': user_token},
        )
        self.assertIn('new bucketlist', str(response.data))
Exemplo n.º 3
0
    def test_update_item(self):
        user_token = base.base_authentication(self)
        base.base_add_item(self)

        update = self.client.put(
            '/api/v1.0/bucketlists/1/items/1/',
            data=json.dumps(dict(name="Climb mount kenya", )),
            headers={'Authorization': user_token},
        )
        data = json.loads(update.data.decode())
        self.assertEqual(data['message'], 'Successfully updated the item')
Exemplo n.º 4
0
    def test_pass_invalid_parameter(self):
        user_token = base.base_authentication(self)
        response = self.client.post(
            '/api/v1.0/bucketlists/',
            data=json.dumps(dict(
                email="*****@*****.**"
            )), headers={'Authorization': user_token},
        )

        data = json.loads(response.data.decode())
        self.assertEqual(data['message'], 'Invalid parameter entered')
Exemplo n.º 5
0
    def test_unnamed_bucetlist(self):
        user_token = base.base_authentication(self)
        response = self.client.post(
            '/api/v1.0/bucketlists/',
            data=json.dumps(dict(
                name="",
            )), headers={'Authorization': user_token},
        )

        data = json.loads(response.data.decode())
        self.assertEqual(data['message'], 'Missing required parameters.')
Exemplo n.º 6
0
    def test_delete_bucketlist(self):
        user_token = base.base_authentication(self)
        base.base_add_bucketlist(self)

        response = self.client.delete(
            '/api/v1.0/bucketlists/1/',
            headers={'Authorization': user_token},
        )

        data = json.loads(response.data.decode())
        self.assertEqual(data['message'], 'Bucketlist successfully deleted')
Exemplo n.º 7
0
    def test_add_existing_bucketlist(self):
        user_token = base.base_authentication(self)
        base.base_add_bucketlist(self)

        response = self.client.post(
            '/api/v1.0/bucketlists/',
            data=json.dumps(dict(
                name="new bucketlist",
            )), headers={'Authorization': user_token},
        )
        data = json.loads(response.data.decode())
        self.assertEqual(data['message'], 'bucketlist already exists')
Exemplo n.º 8
0
    def test_update_bucketlist(self):
        user_token = base.base_authentication(self)
        base.base_add_bucketlist(self)

        response = self.client.put(
            '/api/v1.0/bucketlists/1/',
            data=json.dumps(dict(
                name="revised bucketlist"
            )),
            headers={'Authorization': user_token},
        )

        data = json.loads(response.data.decode())
        self.assertEqual(
            data['message'], 'Successfully updated the bucketlist')