Skip to content

Commit c1bf159

Browse files
committed
POP-2274 implement function, but test is garbage
1 parent 543e5b0 commit c1bf159

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

dynatademand/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def logout(self):
110110
))
111111
return logout_response.json()
112112

113+
def get_attributes(self, country_code, language_code):
114+
return self._api_get('/attributes/{}/{}'.format(country_code, language_code))
115+
113116
def get_project(self, project_id):
114117
return self._api_get('/projects/{}'.format(project_id))
115118

tests/test_attributes.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# encoding: utf-8
2+
from __future__ import unicode_literals, print_function
3+
4+
import json
5+
import unittest
6+
import responses
7+
8+
try:
9+
from unittest.mock import patch
10+
except ImportError:
11+
from mock import patch
12+
13+
from dynatademand.api import DemandAPIClient
14+
15+
BASE_HOST = "http://test-url.example"
16+
17+
18+
class TestAttributeEndpoints(unittest.TestCase):
19+
def setUp(self):
20+
self.api = DemandAPIClient(client_id='test', username='testuser', password='testpass', base_host=BASE_HOST)
21+
self.api._access_token = 'Bearer testtoken'
22+
23+
@responses.activate
24+
def test_get_attributes(self):
25+
with open('./tests/test_files/get_attributes.json', 'r') as attributes_file:
26+
attributes_json = json.load(attributes_file)
27+
responses.add(responses.GET, '{}/sample/v1/attributes/no/no'.format(BASE_HOST), json=attributes_json, status=200)
28+
self.api.get_attributes('no', 'no')
29+
self.assertEqual(len(responses.calls), 1)
30+
print('flaws')
31+
print(responses.calls[0].response.json())
32+
self.assertEqual(responses.calls[0].response.json(), attributes_json)

tests/test_files/get_attributes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"garbage": "this tests nothing"
3+
}

0 commit comments

Comments
 (0)