コード例 #1
0
 def test_06_filter_with_normal_model_with_end_date_wout_start_date(self):
     test_filter = create_search_filter(
         self.spell_id, self.normal_model, None, self.end_date)
     self.assertEqual(
         len(test_filter),
         4,
         'Incorrect number of items in filter'
     )
     spell_filter = test_filter[0]
     model_filter = test_filter[1]
     complete_filter = test_filter[2]
     end_filter = test_filter[3]
     self.assertEqual(
         str(spell_filter),
         "['parent_id', '=', 1]",
         'Incorrect spell activity filter created'
     )
     self.assertEqual(
         str(model_filter),
         "['data_model', '=', 'nh.test']",
         'Incorrect model filter created'
     )
     self.assertEqual(
         str(complete_filter),
         "['state', '=', 'completed']",
         'Incorrect complete filter created'
     )
     self.assertEqual(
         str(end_filter),
         "['date_terminated', '<=', '{0}']".format(
             datetime.strftime(self.end_date, dtf)
         ),
         'Incorrect date start filter created'
     )
コード例 #2
0
 def test_08_filter_with_exception_model_wout_end_date_w_start_date(self):
     test_filter = create_search_filter(
         self.spell_id, self.exception_model2, self.start_date, None)
     self.assertEqual(
         len(test_filter),
         3,
         'Incorrect number of items in filter'
     )
     spell_filter = test_filter[0]
     model_filter = test_filter[1]
     start_filter = test_filter[2]
     self.assertEqual(
         str(spell_filter),
         "['parent_id', '=', 1]",
         'Incorrect spell activity filter created'
     )
     self.assertEqual(
         str(model_filter),
         "['data_model', '=', '{0}']".format(
             self.exception_model2
         ),
         'Incorrect model filter created'
     )
     self.assertEqual(
         str(start_filter),
         "['date_started', '>=', '{0}']".format(
             datetime.strftime(self.start_date, dtf)
         ),
         'Incorrect date start filter created'
     )
コード例 #3
0
 def test_05_filter_with_normal_model_wout_end_date_wout_start_date(self):
     test_filter = create_search_filter(
         self.spell_id,
         self.normal_model,
         None,
         None
     )
     self.assertEqual(
         len(test_filter),
         3,
         'Incorrect number of items in filter'
     )
     spell_filter = test_filter[0]
     model_filter = test_filter[1]
     complete_filter = test_filter[2]
     self.assertEqual(
         str(spell_filter),
         "['parent_id', '=', 1]",
         'Incorrect spell activity filter created'
     )
     self.assertEqual(
         str(model_filter),
         "['data_model', '=', 'nh.test']",
         'Incorrect model filter created'
     )
     self.assertEqual(
         str(complete_filter),
         "['state', '=', 'completed']",
         'Incorrect complete filter created'
     )
コード例 #4
0
 def get_ews_activity_ids_with_clinical_review_in_datetime_range(
         self, spell_activity_id, start_datetime, end_datetime
 ):
     domain = helpers.create_search_filter(
         spell_activity_id, 'nh.clinical.notification.clinical_review',
         start_datetime, end_datetime,
         states=None, date_field='date_scheduled'
     )
     activity_model = self.env['nh.activity']
     clinical_review_notifications = activity_model.search(domain)
     return [clinical_review.creator_id for clinical_review
             in clinical_review_notifications]
コード例 #5
0
    def assert_domain(self, spell_activity_id, model, start_date, end_date,
                      *args):
        test_domain = create_search_filter(
            spell_activity_id, model, start_date, end_date
        )

        domain_parameters_total = 0

        if spell_activity_id:
            domain_parameters_total += 1
            expected_spell_domain = ('parent_id', '=', spell_activity_id)
            actual_spell_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(
                expected_spell_domain, actual_spell_domain,
                'Incorrect spell activity domain created.'
            )

        if model:
            domain_parameters_total += 1
            expected_model_domain = ('data_model', '=', model)
            actual_model_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(
                expected_model_domain, actual_model_domain,
                'Incorrect model domain created.'
            )

        domain_parameters_total += 1
        expected_state_domain = ('state', '=', 'completed')
        actual_state_domain = test_domain[domain_parameters_total - 1]
        self.assertSequenceEqual(expected_state_domain, actual_state_domain,
                                 'Incorrect state domain created.')

        if start_date:
            domain_parameters_total += 1
            expected_start_domain = ('date_terminated', '>=',
                                     datetime.strftime(start_date, dtf))
            actual_start_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(
                expected_start_domain, actual_start_domain,
                'Incorrect start domain created.'
            )

        if end_date:
            domain_parameters_total += 1
            expected_end_domain = ('date_terminated', '<=',
                                   datetime.strftime(end_date, dtf))
            actual_end_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(expected_end_domain, actual_end_domain,
                                     'Incorrect end domain created.')

        self.assertEqual(len(test_domain), domain_parameters_total,
                         'Incorrect number of items in filter.')
コード例 #6
0
    def assert_domain(self, spell_activity_id, model, start_date, end_date,
                      *args):
        test_domain = create_search_filter(
            spell_activity_id, model, start_date, end_date
        )

        domain_parameters_total = 0

        if spell_activity_id:
            domain_parameters_total += 1
            expected_spell_domain = ('parent_id', '=', spell_activity_id)
            actual_spell_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(
                expected_spell_domain, actual_spell_domain,
                'Incorrect spell activity domain created.'
            )

        if model:
            domain_parameters_total += 1
            expected_model_domain = ('data_model', '=', model)
            actual_model_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(
                expected_model_domain, actual_model_domain,
                'Incorrect model domain created.'
            )

        domain_parameters_total += 1
        expected_state_domain = ('state', '=', 'completed')
        actual_state_domain = test_domain[domain_parameters_total - 1]
        self.assertSequenceEqual(expected_state_domain, actual_state_domain,
                                 'Incorrect state domain created.')

        if start_date:
            domain_parameters_total += 1
            expected_start_domain = ('date_terminated', '>=',
                                     datetime.strftime(start_date, dtf))
            actual_start_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(
                expected_start_domain, actual_start_domain,
                'Incorrect start domain created.'
            )

        if end_date:
            domain_parameters_total += 1
            expected_end_domain = ('date_terminated', '<=',
                                   datetime.strftime(end_date, dtf))
            actual_end_domain = test_domain[domain_parameters_total - 1]
            self.assertSequenceEqual(expected_end_domain, actual_end_domain,
                                     'Incorrect end domain created.')

        self.assertEqual(len(test_domain), domain_parameters_total,
                         'Incorrect number of items in filter.')
コード例 #7
0
ファイル: clinical_review.py プロジェクト: jibrel/openeobs
 def get_ews_activity_ids_with_clinical_review_in_datetime_range(
         self, spell_activity_id, start_datetime, end_datetime):
     domain = helpers.create_search_filter(
         spell_activity_id,
         'nh.clinical.notification.clinical_review',
         start_datetime,
         end_datetime,
         states=None,
         date_field='date_scheduled')
     activity_model = self.env['nh.activity']
     clinical_review_notifications = activity_model.search(domain)
     return [
         clinical_review.creator_id
         for clinical_review in clinical_review_notifications
     ]
コード例 #8
0
 def test_09_filter_with_exception_model_out_end_date_wout_start_date(self):
     test_filter = create_search_filter(
         self.spell_id, self.exception_model, None, None)
     self.assertEqual(
         len(test_filter),
         2,
         'Incorrect number of items in filter'
     )
     spell_filter = test_filter[0]
     model_filter = test_filter[1]
     self.assertEqual(
         str(spell_filter),
         "['parent_id', '=', 1]",
         'Incorrect spell activity filter created'
     )
     self.assertEqual(
         str(model_filter),
         "['data_model', '=', '{0}']".format(
             self.exception_model
         ),
         'Incorrect model filter created'
     )
コード例 #9
0
 def test_03_without_model(self):
     with self.assertRaises(ValueError):
         create_search_filter(None, self.normal_model,
                              self.start_date, self.end_date)
コード例 #10
0
 def test_14_without_spell_activity_id(self):
     with self.assertRaises(ValueError):
         create_search_filter(None, None, None, None)
コード例 #11
0
 def test_13_without_model_or_end_date_or_start_date(self):
     with self.assertRaises(ValueError):
         create_search_filter(self.spell_activity_id, None,
                              self.start_date, self.end_date)
コード例 #12
0
 def test_12_filter_without_model_with_end_date_without_start_date(self):
     with self.assertRaises(ValueError):
         create_search_filter(self.spell_id, None, None, self.end_date)
コード例 #13
0
 def test_03_without_model(self):
     with self.assertRaises(ValueError):
         create_search_filter(None, self.normal_model,
                              self.start_date, self.end_date)
コード例 #14
0
 def test_14_without_spell_activity_id(self):
     with self.assertRaises(ValueError):
         create_search_filter(None, None, None, None)
コード例 #15
0
 def test_13_without_model_or_end_date_or_start_date(self):
     with self.assertRaises(ValueError):
         create_search_filter(self.spell_activity_id, None,
                              self.start_date, self.end_date)