Skip to content

Commit f1d7ea2

Browse files
authored
Merge pull request #59 from dynata/feature-expose-studytype
Feature expose studytype
2 parents 75591c1 + c83fec1 commit f1d7ea2

File tree

7 files changed

+71
-13
lines changed

7 files changed

+71
-13
lines changed

dynatademand/api.py

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ def get_countries(self, **kwargs):
158158
)
159159
return self._api_get('/countries', kwargs)
160160

161+
def get_study_metadata(self):
162+
return self._api_get('/studyMetadata')
163+
161164
def get_event(self, event_id):
162165
self.validator.validate_request(
163166
'get_event',

dynatademand/schemas/request/body/create_line_item.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@
4545
"deliveryType": {
4646
"type": "string",
4747
"default": "BALANCED",
48-
"description": "The plan on how responses will flow into the survey.",
49-
"enum": [
50-
"SLOW",
51-
"BALANCED",
52-
"FAST"
53-
]
48+
"description": "The plan on how responses will flow into the survey."
5449
},
5550
"sources": {
5651
"type": "array",

dynatademand/schemas/request/body/create_project.json

+15-6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@
5555
"type": "string",
5656
"minLength": 1
5757
}
58+
},
59+
"studyType": {
60+
"type": "array",
61+
"description": "List of possible types of survey.",
62+
"items": {
63+
"type": "string"
64+
}
65+
},
66+
"surveyRequirements": {
67+
"type": "array",
68+
"description": "List of possible requirements for a survey.",
69+
"items": {
70+
"type": "string"
71+
}
5872
}
5973
}
6074
},
@@ -118,12 +132,7 @@
118132
"deliveryType": {
119133
"type": "string",
120134
"default": "BALANCED",
121-
"description": "The plan on how responses will flow into the survey.",
122-
"enum": [
123-
"SLOW",
124-
"BALANCED",
125-
"FAST"
126-
]
135+
"description": "The plan on how responses will flow into the survey."
127136
},
128137
"sources": {
129138
"type": "array",

dynatademand/schemas/request/body/update_project.json

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
"items": {
2626
"type": "string"
2727
}
28+
},
29+
"studyType": {
30+
"type": "array",
31+
"items": {
32+
"type": "string"
33+
}
34+
},
35+
"studyRequirements": {
36+
"type": "array",
37+
"items": {
38+
"type": "string"
39+
}
2840
}
2941
}
3042
},

tests/test_categories.py

+19
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,22 @@ def test_get_survey_topics(self):
2727
self.api.get_survey_topics()
2828
self.assertEqual(len(responses.calls), 1)
2929
self.assertEqual(responses.calls[0].response.json(), survey_topics_json)
30+
31+
32+
class TestStudyMetadataEndpoint(unittest.TestCase):
33+
def setUp(self):
34+
self.api = DemandAPIClient(client_id='test', username='testuser', password='testpass', base_host=BASE_HOST)
35+
self.api._access_token = 'Bearer testtoken'
36+
37+
@responses.activate
38+
def test_get_study_metadata(self):
39+
with open('./tests/test_files/get_study_metadata.json', 'r') as survey_metadata_file:
40+
survey_metadata_json = json.load(survey_metadata_file)
41+
responses.add(
42+
responses.GET,
43+
'{}/sample/v1/studyMetadata'.format(BASE_HOST),
44+
json=survey_metadata_json,
45+
status=200)
46+
self.api.get_study_metadata()
47+
self.assertEqual(len(responses.calls), 1)
48+
self.assertEqual(responses.calls[0].response.json(), survey_metadata_json)
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"category": {
3+
"studyRequirements": [
4+
{
5+
"allowed": false,
6+
"description": "PII Collection",
7+
"id": "PII_COLLECTION",
8+
"name": "PII Collection"
9+
}
10+
]
11+
},
12+
"deliveryTypes": [
13+
{
14+
"allowed": true,
15+
"description": "Completes come in at an even pace throughout fielding",
16+
"id": "SLOW",
17+
"name": "Slow"
18+
}
19+
]
20+
}

tests/test_files/get_survey_topics.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"survey": {
33
"topic": "milk"
44
}
5-
}
5+
}

0 commit comments

Comments
 (0)