Example #1
0
 def test_subrecord_data_dictionary(self, subrecords):
     subrecords.return_value = [HatWearer]
     dd = extract.get_data_dictionary()
     hat_wearer = dd.pop(HatWearer.get_display_name())
     hats = next(i for i in hat_wearer if i["display_name"] == 'Hats')
     self.assertEqual(hats['type_display_name'], 'Some of the Hats')
     wearing_a_hat = next(i for i in hat_wearer
                          if i["display_name"] == 'Wearing A Hat')
     self.assertEqual(wearing_a_hat['type_display_name'],
                      'Either True or False')
Example #2
0
    def test_context(self):
        """ context should include logic from template
            context processors, but should not
            pollute the global context with this information.
        """
        template = Template(
            '{% load panels %}{{ title }}{% record_panel models.HatWearer %}{{ title }}'
        )
        ctx = {"models": {"HatWearer": HatWearer}, "title": "someTitle"}
        result = str(template.render(Context(ctx)))
        self.assertTrue(result.startswith('someTitle'))
        self.assertTrue(result.endswith('someTitle'))

        # the rest of the result should just use the hat wearter title
        # so lets just remove the start and end
        result = result.split("someTitle", 1)[1].rsplit("someTitle", 1)[0]
        self.assertFalse("someTitle" in result)
        self.assertIn(HatWearer.get_display_name(), result)
    def test_context(self):
        """ context should include logic from template
            context processors, but should not
            pollute the global context with this information.
        """
        template = Template(
            '{% load panels %}{{ title }}{% record_panel models.HatWearer %}{{ title }}'
        )
        ctx = {"models": {"HatWearer": HatWearer}, "title": "someTitle"}
        result = str(template.render(Context(ctx)))
        self.assertTrue(result.startswith('someTitle'))
        self.assertTrue(result.endswith('someTitle'))

        # the rest of the result should just use the hat wearter title
        # so lets just remove the start and end
        result = result.split("someTitle", 1)[1].rsplit("someTitle", 1)[0]
        self.assertFalse("someTitle" in result)
        self.assertIn(HatWearer.get_display_name(), result)
Example #4
0
 def test_get_display_name_from_property(self):
     self.assertEqual('Wearer of Hats', HatWearer.get_display_name())
Example #5
0
 def test_get_display_name_from_property(self):
     self.assertEqual('Wearer of Hats', HatWearer.get_display_name())