Example #1
0
 def test_add_preposition_with_a_filter_without_any_for_its_group(self):
     summary_rules = SummaryRules('Pricing')
     self.assertEqual(
         u"<em>Trial option</em>",
         summary_rules.add_filter_preposition(
             filter_id='Trial option',
             filter_string=u"<em>Trial option</em>"))
 def setUp(self):
     if SummaryRules.loaded is False:
         SummaryRules.load_rules(manifest=os.path.join(
             os.path.dirname(__file__),
             '..',
             '..',
             'app',
             'helpers',
             'search_summary_manifest.yml'
         ))
 def test_add_preposition_with_a_filter_without_in_a_group_with_some(self):
     SummaryRules._rules['Minimum contract period']['filterRules'].remove({
         'preposition': 'an',
         'id': 'Hour'
     })
     summary_rules = SummaryRules('Minimum contract period')
     self.assertEqual(
         u"<em>Hour</em>", summary_rules.add_filter_preposition(
             filter_id='Hour',
             filter_string=u"<em>Hour</em>"))
     # Make SummaryRules to reload its data
     SummaryRules.loaded = False
Example #4
0
 def test_add_preposition_with_a_filter_without_in_a_group_with_some(self):
     SummaryRules._rules['Minimum contract period']['filterRules'].remove({
         'preposition':
         'an',
         'id':
         'Hour'
     })
     summary_rules = SummaryRules('Minimum contract period')
     self.assertEqual(
         u"<em>Hour</em>",
         summary_rules.add_filter_preposition(
             filter_id='Hour', filter_string=u"<em>Hour</em>"))
     # Make SummaryRules to reload its data
     SummaryRules.loaded = False
Example #5
0
 def setUp(self):
     self.rules_instance = SummaryRules('')
     self.rules_instance_mock = Mock()
     self.rules = {
         'id': 'Datacentre tier',
         'labelPreposition': None,
         'label': None,
         'filtersPreposition': None,
         'filterRules': None,
         'conjunction': 'or'
     }
     self.rules_instance_mock.get = self._get_mock
Example #6
0
 def test_add_preposition_with_a_filter_that_has_one(self):
     summary_rules = SummaryRules('Minimum contract period')
     self.assertEqual(
         u"an <em>Hour</em>",
         summary_rules.add_filter_preposition(
             filter_id='Hour', filter_string=u"<em>Hour</em>"))
Example #7
0
 def test_filter_rules_ids_are_set_if_filterRules_exist(self):
     summary_rules = SummaryRules('Minimum contract period')
     self.assertTrue(hasattr(summary_rules, "filter_rules_ids"))
     self.assertEqual(summary_rules.filter_rules_ids,
                      ['Hour', 'Day', 'Month', 'Year', 'Other'])
Example #8
0
 def test_get_method_works_for_empty_key(self):
     summary_rules = SummaryRules('Categories')
     self.assertEqual(summary_rules.get('filterRules'), None)
Example #9
0
 def test_get_method_works_for_key_with_value(self):
     summary_rules = SummaryRules('Categories')
     self.assertEqual(summary_rules.get('conjunction'), 'and')
Example #10
0
 def test_set_up_where_rules_do_exist(self):
     summary_rules = SummaryRules('Categories')
     self.assertTrue(summary_rules.exist)
Example #11
0
 def test_set_up_where_rules_do_not_exist(self):
     summary_rules = SummaryRules('Sites')
     self.assertFalse(summary_rules.exist)
Example #12
0
 def setUp(self):
     if SummaryRules.loaded is False:
         SummaryRules.load_rules(manifest=os.path.join(
             os.path.dirname(__file__), '..', '..', 'app', 'helpers',
             'search_summary_manifest.yml'))
 def test_add_preposition_with_a_filter_without_any_for_its_group(self):
     summary_rules = SummaryRules('Pricing')
     self.assertEqual(
         u"<em>Trial option</em>", summary_rules.add_filter_preposition(
             filter_id='Trial option',
             filter_string=u"<em>Trial option</em>"))
 def test_add_preposition_with_a_filter_that_has_one(self):
     summary_rules = SummaryRules('Minimum contract period')
     self.assertEqual(
         u"an <em>Hour</em>", summary_rules.add_filter_preposition(
             filter_id='Hour', filter_string=u"<em>Hour</em>"))
 def test_get_method_works_for_empty_key(self):
     summary_rules = SummaryRules('Categories')
     self.assertEqual(summary_rules.get('filterRules'), None)
 def test_get_method_works_for_key_with_value(self):
     summary_rules = SummaryRules('Categories')
     self.assertEqual(summary_rules.get('conjunction'), 'and')