Exemplo n.º 1
0
    def setUpClass(cls):
        data = {'name': 'GET Alice'}
        post_json_response = requests.post(
            urls.TEST_COLLECTION_URL,
            data=json.dumps(data),
            headers={
                'content-type': 'application/json'
            }).json()

        pk = post_json_response['id']
        cls.response = requests.delete(urls.test_resource_url(pk))
        cls.get_response = requests.get(urls.test_resource_url(pk))
Exemplo n.º 2
0
    def setUpClass(cls):
        data = {'name': 'PUT Alice', }
        put_data = {'age': 30}
        requests.delete(urls.TEST_ITEM_SCHEMA_URL)
        schema = {
            '$schema': 'http://json-schema.org/draft-03/schema#',
            'collectionName': urls.TEST_COLLECTION_NAME,
            'properties': {
                'name': {'type': 'string'}
            },
            'type': 'object'
        }

        requests.post(
            urls.collection_url('item-schemas'),
            data=json.dumps(schema),
            headers={
                'content-type': 'application/json'
            })
        cls.before_item = requests.post(
            urls.TEST_COLLECTION_URL,
            data=json.dumps(data),
            headers={
                'content-type': 'application/json'
            }).json()

        sleep(1)

        cls.response = requests.put(
            urls.test_resource_url(cls.before_item['id']),
            data=json.dumps(put_data),
            headers={
                'content-type': 'application/json'
            })
        cls.json_response = cls.response.json()
Exemplo n.º 3
0
    def setUpClass(cls):
        data = {
            'name': 'PUT Alice',
        }
        put_data = {'age': 30}
        requests.delete(urls.TEST_ITEM_SCHEMA_URL)
        schema = {
            '$schema': 'http://json-schema.org/draft-03/schema#',
            'collectionName': urls.TEST_COLLECTION_NAME,
            'properties': {
                'name': {
                    'type': 'string'
                }
            },
            'type': 'object'
        }

        requests.post(urls.collection_url('item-schemas'),
                      data=json.dumps(schema),
                      headers={'content-type': 'application/json'})
        cls.before_item = requests.post(urls.TEST_COLLECTION_URL,
                                        data=json.dumps(data),
                                        headers={
                                            'content-type': 'application/json'
                                        }).json()

        sleep(1)

        cls.response = requests.put(
            urls.test_resource_url(cls.before_item['id']),
            data=json.dumps(put_data),
            headers={'content-type': 'application/json'})
        cls.json_response = cls.response.json()
Exemplo n.º 4
0
    def test_invalid_data(self):
        data = {'name': 1992}
        response = requests.put(urls.test_resource_url(self.before_item['id']),
                                data=json.dumps(data),
                                headers={'content-type': 'application/json'})

        response.status_code.should.equal(422)
        errors = response.json()
        errors.should.equal({'errors': {'/name': 'Wrong type'}})
Exemplo n.º 5
0
    def test_invalid_data(self):
        data = {'name': 1992}
        response = requests.put(
            urls.test_resource_url(self.before_item['id']),
            data=json.dumps(data),
            headers={
                'content-type': 'application/json'
            })

        response.status_code.should.equal(422)
        errors = response.json()
        errors.should.equal({'errors': {'/name': 'Wrong type'}})
Exemplo n.º 6
0
    def setUpClass(cls):
        data = {'name': 'PUT Alice'}
        put_data = '///invalid///'

        item = requests.post(urls.TEST_COLLECTION_URL,
                             data=json.dumps(data),
                             headers={
                                 'content-type': 'application/json'
                             }).json()

        cls.response = requests.put(
            urls.test_resource_url(item['id']),
            data=put_data,
            headers={'content-type': 'application/json'})
Exemplo n.º 7
0
    def setUpClass(cls):
        data = {'name': 'PUT Alice'}
        put_data = '///invalid///'

        item = requests.post(
            urls.TEST_COLLECTION_URL,
            data=json.dumps(data),
            headers={
                'content-type': 'application/json'
            }).json()

        cls.response = requests.put(
            urls.test_resource_url(item['id']),
            data=put_data,
            headers={
                'content-type': 'application/json'
            })
Exemplo n.º 8
0
    def setUpClass(cls):
        schema = {
            '$schema': 'http://json-schema.org/draft-03/schema#',
            'collectionName': urls.TEST_COLLECTION_NAME
        }
        requests.post(urls.collection_url('item-schemas'),
                      data=json.dumps(schema),
                      headers={'content-type': 'application/json'})

        data = {'name': 'GET Alice'}
        item = requests.post(urls.TEST_COLLECTION_URL,
                             data=json.dumps(data),
                             headers={
                                 'content-type': 'application/json'
                             }).json()

        cls.response = requests.get(urls.test_resource_url(item['id']))
        cls.json_response = cls.response.json()
Exemplo n.º 9
0
    def setUpClass(cls):
        schema = {
            '$schema': 'http://json-schema.org/draft-03/schema#',
            'collectionName': urls.TEST_COLLECTION_NAME
        }
        requests.post(
            urls.collection_url('item-schemas'),
            data=json.dumps(schema),
            headers={
                'content-type': 'application/json'
            })

        data = {'name': 'GET Alice'}
        item = requests.post(
            urls.TEST_COLLECTION_URL,
            data=json.dumps(data),
            headers={
                'content-type': 'application/json'
            }).json()

        cls.response = requests.get(urls.test_resource_url(item['id']))
        cls.json_response = cls.response.json()
Exemplo n.º 10
0
 def test_location_header(self):
     location_url = urls.test_resource_url(self.json_response['id'])
     self.response.headers['location'].should.equal(location_url)
Exemplo n.º 11
0
 def test_location_header(self):
     location_url = urls.test_resource_url(self.json_response['id'])
     self.response.headers['location'].should.equal(location_url)
Exemplo n.º 12
0
 def setUpClass(cls):
     cls.response = requests.get(urls.test_resource_url('not-found'))
Exemplo n.º 13
0
 def setUpClass(cls):
     cls.response = requests.get(urls.test_resource_url('not-found'))