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') assert summary_rules.add_filter_preposition( filter_id='Hour', filter_string=u"<strong>Hour</strong>", ) == u"<strong>Hour</strong>" # Make SummaryRules to reload its data SummaryRules.loaded = False
def setup_method(self, method): 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
def test_add_preposition_with_a_filter_without_any_for_its_group(self): summary_rules = SummaryRules('Pricing') assert summary_rules.add_filter_preposition( filter_id='Trial option', filter_string=u"<strong>Trial option</strong>", ) == u"<strong>Trial option</strong>"
def test_filter_rules_ids_are_set_if_filterRules_exist(self): summary_rules = SummaryRules('Minimum contract period') assert hasattr(summary_rules, "filter_rules_ids") assert summary_rules.filter_rules_ids == [ 'Hour', 'Day', 'Month', 'Year', 'Other' ]
def test_add_preposition_with_a_filter_that_has_one(self): summary_rules = SummaryRules('Minimum contract period') assert u"an <strong>Hour</strong>" == summary_rules.add_filter_preposition( filter_id='Hour', filter_string=u"<strong>Hour</strong>", )
def test_get_method_works_for_empty_key(self): summary_rules = SummaryRules('Categories') assert summary_rules.get('filterRules') is None
def test_get_method_works_for_key_with_value(self): summary_rules = SummaryRules('Categories') assert summary_rules.get('conjunction') == 'and'
def test_set_up_where_rules_do_exist(self): summary_rules = SummaryRules('Categories') assert summary_rules.exist
def test_set_up_where_rules_do_not_exist(self): summary_rules = SummaryRules('Sites') assert not summary_rules.exist
def setup_method(self, method): if SummaryRules.loaded is False: SummaryRules.load_rules(manifest=os.path.join( os.path.dirname(__file__), '..', '..', 'app', 'helpers', 'search_summary_manifest.yml'))