Feat: Se agrega GET party
This commit is contained in:
parent
cd1450e11b
commit
ad90f666d1
@ -36,6 +36,32 @@ def parties(request, pool):
|
|||||||
party.save()
|
party.save()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route(
|
||||||
|
'/<database_name>/sale_don_confiao/party/<party>',
|
||||||
|
methods=['GET'])
|
||||||
|
@allow_null_origin
|
||||||
|
@with_pool
|
||||||
|
@with_transaction()
|
||||||
|
@don_confiao_application
|
||||||
|
def party(request, pool, party: int):
|
||||||
|
Party = pool.get('party.party')
|
||||||
|
if request.method == 'GET':
|
||||||
|
parties = Party.search_read(
|
||||||
|
[],
|
||||||
|
order=[('id', 'ASC')],
|
||||||
|
fields_names=['id', 'name'])
|
||||||
|
return parties
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
data = json.loads(
|
||||||
|
request.get_data().decode()
|
||||||
|
)
|
||||||
|
|
||||||
|
party = Party()
|
||||||
|
party.name = data['name']
|
||||||
|
party.save()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<database_name>/sale_don_confiao/products', methods=['GET'])
|
@app.route('/<database_name>/sale_don_confiao/products', methods=['GET'])
|
||||||
@allow_null_origin
|
@allow_null_origin
|
||||||
@with_pool
|
@with_pool
|
||||||
|
@ -46,6 +46,17 @@ class DonConfiaoApiRouteTestCase(
|
|||||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||||
self.assertEqual(len(parties), 1)
|
self.assertEqual(len(parties), 1)
|
||||||
|
|
||||||
|
def test_get_party(self):
|
||||||
|
client = self.client()
|
||||||
|
response = client.get(
|
||||||
|
f'/{self.db_name}/sale_don_confiao/party/1',
|
||||||
|
headers={
|
||||||
|
'Authorization': f'bearer {self.key}',
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||||
|
self.assertIsNotNone(response.get_data())
|
||||||
|
|
||||||
def test_post_parties(self):
|
def test_post_parties(self):
|
||||||
client = self.client()
|
client = self.client()
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
Loading…
Reference in New Issue
Block a user