Skip to content

Commit 5edce1a

Browse files
committed
finish with get_invoices_summary
1 parent f72da5d commit 5edce1a

File tree

7 files changed

+42
-9
lines changed

7 files changed

+42
-9
lines changed

dynatademand/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,5 +431,4 @@ def get_invoices_summary(self, **kwargs):
431431
'get_invoices_summary',
432432
query_params=kwargs
433433
)
434-
435434
return self._api_get('/projects/invoices/summary', kwargs)

dynatademand/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from dynatademand.api import DemandAPIClient
2+
3+
api = DemandAPIClient(client_id='api', username='test', password='test', base_host='https://api.dev.pe.dynata.com')
4+
api.authenticate()
5+
6+
result = api.get_invoices_summary(startDate='2019-06-12', endDate='2019-06-19', extProjectId='010528ef-8984-48c1-a06d-4dae730da027')
7+
8+
print(result)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
165 KB
Binary file not shown.

tests/test_invoices_summary.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# encoding: utf-8
2+
3+
import json
4+
import unittest
5+
import responses
6+
from dynatademand.api import DemandAPIClient
7+
8+
BASE_HOST = "http://test-url.example"
9+
10+
START_DATE = '2019-06-12'
11+
END_DATE = '2019-06-19'
12+
EXT_PROJECT_ID = '010528ef-8984-48c1-a06d-4dae730da027'
13+
14+
class TestInvoicesSummaryEndpoints(unittest.TestCase):
15+
def setUp(self):
16+
self.api = DemandAPIClient(client_id='test', username='testuser', password='testpass', base_host=BASE_HOST)
17+
self.api._access_token = 'Bearer testtoken'
18+
19+
@responses.activate
20+
def test_get_invoices_summary(self):
21+
with open('./tests/test_files/get_invoices_summary.pdf', 'rb') as summary_file:
22+
responses.add(
23+
responses.GET,
24+
'{}/sample/v1/projects/invoices/summary'.format(BASE_HOST),
25+
body=summary_file.read(),
26+
content_type='application/pdf',
27+
stream=True,
28+
status=200)
29+
30+
self.api.get_invoices_summary(startDate=START_DATE, endDate=END_DATE, extProjectId=EXT_PROJECT_ID)
31+
self.assertEqual(len(responses.calls), 1)
32+
self.assertEqual(responses.calls[0].response.headers['content-type'], 'application/pdf')

tests/test_line_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.03# encoding: utf-8
21
from __future__ import unicode_literals, print_function
2+
# encoding: utf-8
33

44
import json
55
import unittest

tests/test_summary.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)