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))
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()
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()
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'}})
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'}})
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'})
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' })
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()
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()
def test_location_header(self): location_url = urls.test_resource_url(self.json_response['id']) self.response.headers['location'].should.equal(location_url)
def test_location_header(self): location_url = urls.test_resource_url(self.json_response['id']) self.response.headers['location'].should.equal(location_url)
def setUpClass(cls): cls.response = requests.get(urls.test_resource_url('not-found'))
def setUpClass(cls): cls.response = requests.get(urls.test_resource_url('not-found'))