@@ -51,13 +51,13 @@ def test_create_respondent_url(fun):
5151 fun .return_value = TEST_DATE_STR
5252
5353 signed_url = GATEWAY .create_respondent_url (
54- 'https://respondent.qa-rex.dynata.com/start'
55- '?ctx=7c26bf58'
56- '-43db-4370-977d-d14fa4356930&language=es' ,
57- '1989-09-16' ,
58- 'male' ,
59- '00000' ,
60- '12345' )
54+ 'https://respondent.qa-rex.dynata.com/start'
55+ '?ctx=7c26bf58'
56+ '-43db-4370-977d-d14fa4356930&language=es' ,
57+ '1989-09-16' ,
58+ 'male' ,
59+ '00000' ,
60+ '12345' )
6161 assert expected == signed_url
6262
6363
@@ -291,7 +291,7 @@ def test_get_respondent_disposition_complete():
291291 "&signature=386b8ad95a284f9e944dd0" \
292292 "12dfc92c1872790a9bad2e00e19b57c346fb725629"
293293
294- assert GATEWAY .get_respondent_disposition (url ) == GatewayDispositionsEnum ['COMPLETE' ] # noqa
294+ assert GATEWAY .get_respondent_disposition (url ) == GatewayDispositionsEnum ['COMPLETE' ] # noqa
295295
296296
297297def test_get_respondent_disposition_does_not_exist ():
@@ -311,38 +311,38 @@ def test_get_respondent_disposition_does_not_exist():
311311
312312def test_get_respondent_disposition_missing_disposition ():
313313 url = "https://respondent.qa-rex.dynata.com/start" \
314- "?ctx=7c26bf58-43db-4370-977d-d14fa4356930" \
315- "&language=es" \
316- "&access_key=access_key" \
317- "&secret_key=secret_key" \
318- "&expiration=2099-01-01T00:00:00.000Z" \
319- "&signature=386b8ad95a284f9e944dd01" \
320- "2dfc92c1872790a9bad2e00e19b57c346fb725629"
314+ "?ctx=7c26bf58-43db-4370-977d-d14fa4356930" \
315+ "&language=es" \
316+ "&access_key=access_key" \
317+ "&secret_key=secret_key" \
318+ "&expiration=2099-01-01T00:00:00.000Z" \
319+ "&signature=386b8ad95a284f9e944dd01" \
320+ "2dfc92c1872790a9bad2e00e19b57c346fb725629"
321321 assert not GATEWAY .get_respondent_disposition (url )
322322
323323
324324def test_get_respondent_status_missing_disposition ():
325325 url = "https://respondent.qa-rex.dynata.com/start" \
326- "?ctx=7c26bf58-43db-4370-977d-d14fa4356930" \
327- "&language=es" \
328- "&access_key=access_key" \
329- "&secret_key=secret_key" \
330- "&expiration=2099-01-01T00:00:00.000Z" \
331- "&signature=386b8ad95a284f9e944dd01" \
332- "2dfc92c1872790a9bad2e00e19b57c346fb725629"
326+ "?ctx=7c26bf58-43db-4370-977d-d14fa4356930" \
327+ "&language=es" \
328+ "&access_key=access_key" \
329+ "&secret_key=secret_key" \
330+ "&expiration=2099-01-01T00:00:00.000Z" \
331+ "&signature=386b8ad95a284f9e944dd01" \
332+ "2dfc92c1872790a9bad2e00e19b57c346fb725629"
333333 assert not GATEWAY .get_respondent_status (url )
334334
335335
336336def test_get_respondent_status_missing_status ():
337337 url = "https://respondent.qa-rex.dynata.com/start" \
338- "?ctx=7c26bf58-43db-4370-977d-d14fa4356930" \
339- "&language=es" \
340- "&access_key=access_key" \
341- "&secret_key=secret_key" \
342- "&disposition=2" \
343- "&expiration=2099-01-01T00:00:00.000Z" \
344- "&signature=386b8ad95a284f9e944dd01" \
345- "2dfc92c1872790a9bad2e00e19b57c346fb725629"
338+ "?ctx=7c26bf58-43db-4370-977d-d14fa4356930" \
339+ "&language=es" \
340+ "&access_key=access_key" \
341+ "&secret_key=secret_key" \
342+ "&disposition=2" \
343+ "&expiration=2099-01-01T00:00:00.000Z" \
344+ "&signature=386b8ad95a284f9e944dd01" \
345+ "2dfc92c1872790a9bad2e00e19b57c346fb725629"
346346 assert not GATEWAY .get_respondent_status (url )
347347
348348
@@ -358,7 +358,7 @@ def test_get_respondent_status():
358358 "&signature=386b8ad95a284f9e944dd01" \
359359 "2dfc92c1872790a9bad2e00e19b57c346fb725629"
360360
361- assert GATEWAY .get_respondent_status (url ) == GatewayStatusEnum .COMPLETE_DEFAULT # noqa
361+ assert GATEWAY .get_respondent_status (url ) == GatewayStatusEnum .COMPLETE_DEFAULT # noqa
362362
363363
364364def test_get_respondent_status_does_not_exist ():
@@ -387,11 +387,11 @@ def test_create_context(fun):
387387 context = GATEWAY .create_context (
388388 "12345" ,
389389 {
390- "ctx" : "a987dsglh34t435jkhsdg98u" ,
391- "gender" : "male" ,
392- "postal_code" : "60081" ,
393- "birth_date" : "1959-10-05" ,
394- "country" : "US"
390+ "ctx" : "a987dsglh34t435jkhsdg98u" ,
391+ "gender" : "male" ,
392+ "postal_code" : "60081" ,
393+ "birth_date" : "1959-10-05" ,
394+ "country" : "US"
395395 }
396396 )
397397 assert expected == context
@@ -432,3 +432,137 @@ def test_get_context(fun):
432432
433433 context = GATEWAY .get_context (12345 )
434434 assert context == expected
435+
436+
437+ @patch .object (requests .Session , "post" )
438+ def test_get_attributes (fun ):
439+ expected = {
440+ "data" : [
441+ {
442+ "active" : "bool" ,
443+ "parameter_id" : "int"
444+ }
445+ ]
446+ }
447+ fun .return_value = ResponseMock ._response_mock (
448+ 200 ,
449+ content = json .dumps ({
450+ "data" : [
451+ {
452+ "active" : "bool" ,
453+ "parameter_id" : "int"
454+ }
455+ ]
456+ }),
457+ content_type = "text/plain"
458+ )
459+ context = GATEWAY .get_attributes ("US" , 0 , 100 )
460+ assert context == expected
461+
462+
463+ @patch .object (requests .Session , "post" )
464+ def test_get_attribute_info (fun ):
465+ expected = {
466+ "id" : "int" ,
467+ "name" : "string" ,
468+ "description" : "string" ,
469+ "display_mode" : "string" ,
470+ "parent_dependencies" : [
471+ {
472+ "answer_ids" : [
473+ {
474+ "id" : "int"
475+ }
476+ ],
477+ "parameter_id" : "int"
478+ }
479+ ],
480+ "expiration_duration" : "int" ,
481+ "is_active" : "bool" ,
482+ "countries" : [
483+ {
484+ "code" : "string"
485+ }
486+ ],
487+ "question" : {
488+ "text" : "string" ,
489+ "translations" : [
490+ {
491+ "locale" : "string" ,
492+ "text" : "string"
493+ }
494+ ]
495+ },
496+ "answers" : [
497+ {
498+ "id" : "int" ,
499+ "text" : "string" ,
500+ "countries" : [
501+ {
502+ "code" : "string"
503+ }
504+ ],
505+ "translations" : [
506+ {
507+ "locale" : "string" ,
508+ "text" : "string"
509+ }
510+ ]
511+ }
512+ ]
513+ }
514+ fun .return_value = ResponseMock ._response_mock (
515+ 200 ,
516+ content = json .dumps ({
517+ "id" : "int" ,
518+ "name" : "string" ,
519+ "description" : "string" ,
520+ "display_mode" : "string" ,
521+ "parent_dependencies" : [
522+ {
523+ "answer_ids" : [
524+ {
525+ "id" : "int"
526+ }
527+ ],
528+ "parameter_id" : "int"
529+ }
530+ ],
531+ "expiration_duration" : "int" ,
532+ "is_active" : "bool" ,
533+ "countries" : [
534+ {
535+ "code" : "string"
536+ }
537+ ],
538+ "question" : {
539+ "text" : "string" ,
540+ "translations" : [
541+ {
542+ "locale" : "string" ,
543+ "text" : "string"
544+ }
545+ ]
546+ },
547+ "answers" : [
548+ {
549+ "id" : "int" ,
550+ "text" : "string" ,
551+ "countries" : [
552+ {
553+ "code" : "string"
554+ }
555+ ],
556+ "translations" : [
557+ {
558+ "locale" : "string" ,
559+ "text" : "string"
560+ }
561+ ]
562+ }
563+ ]
564+ }),
565+ content_type = "text/plain"
566+ )
567+ context = GATEWAY .get_attribute_info (402 )
568+ assert context == expected
0 commit comments