def test_fragment_with_label_and_three_filters_with_prepositions(self):

        def _add_preposition(filter_id=None, filter_string=None):
            if filter_id == 'TIA-942 Tier 1':
                preposition = 'with a'
            elif filter_id == 'uptime institute tier 1':
                preposition = 'met with a'
            elif filter_id == 'uptime institute tier 2':
                preposition = 'aligned with'
            return u"{} {}".format(preposition, filter_string)

        id = 'Datacentre tier'
        filters = [
            'TIA-942 Tier 1',
            'uptime institute tier 1',
            'uptime institute tier 2']
        self.rules['label'] = {
            'singular': 'datacentre tier',
            'plural': 'datacentre tiers'
        }
        self.rules['filterRules'] = []  # filterRules just needs to be set
        self.rules_instance_mock.filter_rules_ids = filters
        self.rules_instance_mock.add_filter_preposition = _add_preposition
        summary_fragment = SummaryFragment(
            id, filters, self.rules_instance_mock)
        self.assertEqual(
            summary_fragment.str(),
            u"datacentre tiers with a <em>TIA-942 Tier 1</em>" +
            u", met with a <em>uptime institute tier 1</em>" +
            u" or aligned with <em>uptime institute tier 2</em>")
Ejemplo n.º 2
0
    def test_fragment_with_label_and_three_filters_with_prepositions(self):
        def _add_preposition(filter_id=None, filter_string=None):
            if filter_id == 'TIA-942 Tier 1':
                preposition = 'with a'
            elif filter_id == 'uptime institute tier 1':
                preposition = 'met with a'
            elif filter_id == 'uptime institute tier 2':
                preposition = 'aligned with'
            return u"{} {}".format(preposition, filter_string)

        id = 'Datacentre tier'
        filters = [
            'TIA-942 Tier 1', 'uptime institute tier 1',
            'uptime institute tier 2'
        ]
        self.rules['label'] = {
            'singular': 'datacentre tier',
            'plural': 'datacentre tiers'
        }
        self.rules['filterRules'] = []  # filterRules just needs to be set
        self.rules_instance_mock.filter_rules_ids = filters
        self.rules_instance_mock.add_filter_preposition = _add_preposition
        summary_fragment = SummaryFragment(id, filters,
                                           self.rules_instance_mock)
        self.assertEqual(
            summary_fragment.str(),
            u"datacentre tiers with a <em>TIA-942 Tier 1</em>" +
            u", met with a <em>uptime institute tier 1</em>" +
            u" or aligned with <em>uptime institute tier 2</em>")
 def test_fragment_with_no_label_and_single_filter(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     summary_fragment = SummaryFragment(
         id, filters, self.rules_instance_mock)
     self.assertEqual(
         summary_fragment.str(), u"<em>TIA-942 Tier 1</em>")
Ejemplo n.º 4
0
 def test_str_method_works(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     summary_fragment = SummaryFragment(id, filters,
                                        self.rules_instance_mock)
     summary_fragment.label_string = u"categories"
     summary_fragment.filters = [u"FreeOption"]
     self.rules['filtersPreposition'] = 'with'
     self.assertEqual(summary_fragment.str(), u"categories with FreeOption")
 def test_str_method_works(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     summary_fragment = SummaryFragment(
         id, filters, self.rules_instance_mock)
     summary_fragment.label_string = u"categories"
     summary_fragment.filters = [u"FreeOption"]
     self.rules['filtersPreposition'] = 'with'
     self.assertEqual(summary_fragment.str(), u"categories with FreeOption")
Ejemplo n.º 6
0
 def test_fragment_with_label_and_one_filter(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     self.rules['label'] = {
         'singular': 'datacentre tier',
         'plural': 'datacentre tier'
     }
     summary_fragment = SummaryFragment(id, filters,
                                        self.rules_instance_mock)
     self.assertEqual(summary_fragment.str(),
                      u"datacentre tier <em>TIA-942 Tier 1</em>")
 def test_fragment_with_label_and_one_filter(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     self.rules['label'] = {
         'singular': 'datacentre tier',
         'plural': 'datacentre tier'
     }
     summary_fragment = SummaryFragment(
         id, filters, self.rules_instance_mock)
     self.assertEqual(
         summary_fragment.str(), u"datacentre tier <em>TIA-942 Tier 1</em>")
Ejemplo n.º 8
0
 def test_fragment_has_correct_form_for_multiple_filters(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1', 'uptime institute tier 1']
     summary_fragment = SummaryFragment(id, filters,
                                        self.rules_instance_mock)
     self.assertTrue(hasattr(summary_fragment, 'form'))
     self.assertEqual(summary_fragment.form, 'plural')
Ejemplo n.º 9
0
 def test_fragment_has_correct_form_for_a_single_filter(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     summary_fragment = SummaryFragment(id, filters,
                                        self.rules_instance_mock)
     self.assertTrue(hasattr(summary_fragment, 'form'))
     self.assertEqual(summary_fragment.form, 'singular')
Ejemplo n.º 10
0
 def test_fragment_with_label_and_three_filters(self):
     id = 'Datacentre tier'
     filters = [
         'TIA-942 Tier 1', 'uptime institute tier 1',
         'uptime institute tier 2'
     ]
     self.rules['label'] = {
         'singular': 'datacentre tier',
         'plural': 'datacentre tiers'
     }
     summary_fragment = SummaryFragment(id, filters,
                                        self.rules_instance_mock)
     self.assertEqual(
         summary_fragment.str(),
         u"datacentre tiers <em>TIA-942 Tier 1</em>" +
         u", <em>uptime institute tier 1</em>" +
         u" or <em>uptime institute tier 2</em>")
 def test_fragment_with_label_and_three_filters(self):
     id = 'Datacentre tier'
     filters = [
         'TIA-942 Tier 1',
         'uptime institute tier 1',
         'uptime institute tier 2']
     self.rules['label'] = {
         'singular': 'datacentre tier',
         'plural': 'datacentre tiers'
     }
     summary_fragment = SummaryFragment(
         id, filters, self.rules_instance_mock)
     self.assertEqual(
         summary_fragment.str(),
         u"datacentre tiers <em>TIA-942 Tier 1</em>" +
         u", <em>uptime institute tier 1</em>" +
         u" or <em>uptime institute tier 2</em>")
Ejemplo n.º 12
0
 def test_fragment_with_no_label_and_single_filter(self):
     id = 'Datacentre tier'
     filters = ['TIA-942 Tier 1']
     summary_fragment = SummaryFragment(id, filters,
                                        self.rules_instance_mock)
     self.assertEqual(summary_fragment.str(), u"<em>TIA-942 Tier 1</em>")