Пример #1
0
    def setUp(self):
        json_path = 'rack/tests/json/dilbert_latest.json'
        strips = _parse_json_data(json_path)
        self.latest_dilbert = strips[0]

        self.comic = ComicFactory.create(dosage_name='Dilbert')
        # xkcd has a quirk module
        self.xkcd = ComicFactory.create(dosage_name='xkcd')
Пример #2
0
 def test_name_property(self):
     names = [
         ('BetweenFailures', None, 'Between Failures'),
         ('Arcamax/MotherGooseAndGrimm', None, 'Mother Goose And Grimm (Arcamax)'),
         ('SnafuComics/PowerPuffGirls', 'The Powerpuff Girls (Snafu Comics)', None),
     ]
     for data in names:
         comic = ComicFactory.create(dosage_name=data[0], override_name=data[1])
         if data[2]:
             self.assertEqual(comic.name, data[2])
         else:
             self.assertEqual(comic.name, data[1])
Пример #3
0
    def test_basic_quirk_functions(self, mock_copy):
        json_path = 'rack/tests/json/xkcd_latest.json'
        xkcd = ComicFactory.create(dosage_name='xkcd')

        strips = _parse_json_data(json_path)

        strip = Strip.objects.get_or_create_with_images(xkcd, strips[0])
        copy_call_args = mock_copy.call_args[0]
        self.assertEqual(copy_call_args[0], 'dosage/xkcd/dummy.txt')
        self.assertEqual(
            copy_call_args[1], os.path.join(settings.MEDIA_ROOT, 'strips/xkcd/dummy.txt'))

        mock_open = MagicMock(name='open')
        mock_open.return_value = StringIO("dummy alt text")
        with mock.patch('builtins.open', mock_open):
            context = strip.quirk.get_extra_context(xkcd, strip)

        self.assertDictEqual(context, {
            'alt_text': 'dummy alt text'
        })
Пример #4
0
 def setUp(self):
     self.comic = comic = ComicFactory.create()
Пример #5
0
 def setUp(self):
     self.comic = ComicFactory.create(dosage_name='Dilbert')