Skip to content

Commit 0935804

Browse files
authored
Merge pull request #15 from researchnow/POP-2283
get survey topics
2 parents 3ef9f66 + 7365a37 commit 0935804

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
@@ -170,5 +170,8 @@ def get_line_item_detailed_report(self, project_id, line_item_id):
170170
def get_feasibility(self, project_id):
171171
return self._api_get('/projects/{}/feasibility'.format(project_id))
172172

173+
def get_survey_topics(self):
174+
return self._api_get('/categories/surveyTopics')
175+
173176
def get_sources(self):
174177
return self._api_get('/sources')

tests/test_categories.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 TestCategoryEndpoints(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_survey_topics(self):
25+
with open('./tests/test_files/get_survey_topics.json', 'r') as survey_topics_file:
26+
survey_topics_json = json.load(survey_topics_file)
27+
responses.add(responses.GET, '{}/sample/v1/categories/surveyTopics'.format(BASE_HOST), json=survey_topics_json, status=200)
28+
self.api.get_survey_topics()
29+
self.assertEqual(len(responses.calls), 1)
30+
self.assertEqual(responses.calls[0].response.json(), survey_topics_json)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"survey": {
3+
"topic": "milk"
4+
}
5+
}

0 commit comments

Comments
 (0)