Пример #1
0
 def test_should_use_visibility_rules_when_preference_exists_but_not_for_a_given_field(
         self):
     preference = UserQuestionnairePreference(self.manager, 1, 'project_id')
     preference.analysis_fields = {'guid-idnr_details.q2': True}
     self.assertFalse(detect_visibility(preference, "guid-idnr_details.q5"))
     self.assertTrue(detect_visibility(preference, "guid-idnr_details.q6"))
     preference.analysis_fields = {'guid-idnr_details.q2': False}
     self.assertTrue(detect_visibility(preference, "guid-idnr_details.q6"))
     self.assertTrue(detect_visibility(preference, "blah"))
Пример #2
0
 def test_should_show_fields(self):
     analysis_fields = [{
         'id': 'Eid',
         'visibility': False
     }, {
         'id': 'q1',
         'visibility': False
     }, {
         'id': 'q2',
         'visibility': False
     }]
     expected = [{
         'id': 'Eid',
         'visibility': True
     }, {
         'id': 'q1',
         'visibility': False
     }, {
         'id': 'q2',
         'visibility': True
     }]
     preference = UserQuestionnairePreference(self.manager, 1, 'project_id')
     preference.analysis_fields = analysis_fields
     preference.save()
     self.assertEqual(preference.analysis_fields, analysis_fields)
     preference.show_fields(['q2', 'Eid'])
     preference.save()
     self.assertEqual(preference.analysis_fields, expected)
Пример #3
0
 def test_should_return_analysis_fields(self):
     analysis_fields = [{'id': 'Eid', 'visibility': True}]
     preference = UserQuestionnairePreference(self.manager, 1, 'project_id')
     preference.analysis_fields = analysis_fields
     preference.save()
     self.assertEqual(preference.analysis_fields, analysis_fields)
Пример #4
0
 def test_should_use_user_preference(self):
     preference = UserQuestionnairePreference(self.manager, 1, 'project_id')
     preference.analysis_fields = {'guid-idnr_details.q3': True}
     self.assertTrue(detect_visibility(preference, "guid-idnr_details.q3"))
     preference.analysis_fields = {'guid-idnr_details.q3': False}
     self.assertFalse(detect_visibility(preference, "guid-idnr_details.q3"))
Пример #5
0
 def test_should_save_preference(self):
     preference = UserQuestionnairePreference(self.manager, 1, 'project_id')
     preference.analysis_fields = {'id': 'Eid', 'visibility': True}
     doc_id = preference.save()
     self.assertIsNotNone(doc_id)