Exemple #1
0
 def test_get_form_details_for_app_and_module_no_data(self):
     self.assertEqual([],
                      get_form_details_for_app_and_module(
                          'missing', self.app.id, 0))
     self.assertEqual([],
                      get_form_details_for_app_and_module(
                          self.domain, 'missing', 0))
     self.assertEqual([],
                      get_form_details_for_app_and_module(
                          self.domain, self.app.id, 3))
Exemple #2
0
 def get_filtered_data_for_parsed_params(domain, parsed_params):
     # this code path has multiple forks:
     # 0. if status isn't set (which cory doesn't think is possible) it defaults to filtering by
     #    status "active". otherwise it will set status to be "active" or "deleted" depending
     #    on what's passed in.
     # 1. if status is set, but nothing else is, it will return all forms in apps of that status
     # 2. if status and app_id are set, but nothing else, it will return all forms in that app
     # 3. if status and app_id and module_id are set, it will return all forms in that module if
     #    the module is valid, otherwise it falls back to the app
     # 4. if status, app_id, module_id, and xmlns are set (which cory doesn't think is possible)
     #    it returns that form.
     deleted = parsed_params.status == PARAM_VALUE_STATUS_DELETED
     _assert = soft_assert(to='@'.join(['czue', 'dimagi.com']))
     if parsed_params.module is not None and parsed_params.get_module_int() is None:
         # todo: remove anytime in 2016
         _assert(False, "module set but not a valid number!")
         return get_form_details_for_app(domain, parsed_params.app_id, deleted=deleted)
     elif parsed_params.most_granular_filter == 'xmlns':
         # todo: remove anytime in 2016
         _assert(False, "got to form ID even though this shouldn't be possible")
         return get_form_details_for_app_and_xmlns(
             domain, parsed_params.app_id, parsed_params.xmlns, deleted=deleted)
     elif parsed_params.most_granular_filter == 'module':
         return get_form_details_for_app_and_module(
             domain, parsed_params.app_id, parsed_params.get_module_int(), deleted=deleted
         )
     elif parsed_params.most_granular_filter == 'app_id':
         return get_form_details_for_app(domain, parsed_params.app_id, deleted=deleted)
     elif parsed_params.most_granular_filter == 'status':
         return get_all_form_details(domain, deleted=deleted)
     else:
         # todo: remove anytime in 2016
         _assert(False, 'most granular filter was a surprising value ({}).'.format(
             parsed_params.most_granular_filter))
         return get_all_form_details(domain)
Exemple #3
0
 def get_filtered_data_for_parsed_params(domain, parsed_params):
     # this code path has multiple forks:
     # 1. if status is set, but nothing else is, it will return all forms in apps of that status
     # 2. if status and app_id are set, but nothing else, it will return all forms in that app
     # 3. if status and app_id and module_id are set, it will return all forms in that module if
     #    the module is valid, otherwise it falls back to the app
     deleted = parsed_params.status == PARAM_VALUE_STATUS_DELETED
     if parsed_params.most_granular_filter == 'module':
         return get_form_details_for_app_and_module(
             domain, parsed_params.app_id, parsed_params.get_module_int(), deleted=deleted
         )
     elif parsed_params.most_granular_filter == 'app_id':
         return get_form_details_for_app(domain, parsed_params.app_id, deleted=deleted)
     elif parsed_params.most_granular_filter == 'status':
         return get_all_form_details(domain, deleted=deleted)
Exemple #4
0
 def get_filtered_data_for_parsed_params(domain, parsed_params):
     # this code path has multiple forks:
     # 1. if status is set, but nothing else is, it will return all forms in apps of that status
     # 2. if status and app_id are set, but nothing else, it will return all forms in that app
     # 3. if status and app_id and module_id are set, it will return all forms in that module if
     #    the module is valid, otherwise it falls back to the app
     deleted = parsed_params.status == PARAM_VALUE_STATUS_DELETED
     if parsed_params.most_granular_filter == 'module':
         return get_form_details_for_app_and_module(
             domain, parsed_params.app_id, parsed_params.get_module_int(), deleted=deleted
         )
     elif parsed_params.most_granular_filter == 'app_id':
         return get_form_details_for_app(domain, parsed_params.app_id, deleted=deleted)
     elif parsed_params.most_granular_filter == 'status':
         return get_all_form_details(domain, deleted=deleted)
 def test_get_form_details_for_app_and_module(self):
     for i in range(2):
         [details] = get_form_details_for_app_and_module(self.domain, self.app.id, i)
         self._assert_form_details_match(i, details)
 def test_get_form_details_for_app_and_module_no_data(self):
     self.assertEqual([], get_form_details_for_app_and_module('missing', self.app.id, 0))
     self.assertEqual([], get_form_details_for_app_and_module(self.domain, 'missing', 0))
     self.assertEqual([], get_form_details_for_app_and_module(self.domain, self.app.id, 3))
Exemple #7
0
 def test_get_form_details_for_app_and_module(self):
     for i in range(2):
         [details] = get_form_details_for_app_and_module(self.domain, self.app.id, i)
         self._assert_form_details_match(i, details)