Beispiel #1
0
 def test_generate_multilingual(self):
     configuration = Configuration('/tmp', 'https://example.com')
     configuration.locales.clear()
     configuration.locales['nl'] = LocaleConfiguration('nl')
     configuration.locales['en'] = LocaleConfiguration('en')
     sut = LocalizedPathUrlGenerator(configuration)
     self.assertEquals('/nl/index.html',
                       sut.generate('/index.html', 'text/html'))
     self.assertEquals(
         '/en/index.html', sut.generate('/index.html', 'text/html', locale='en'))
Beispiel #2
0
 def test_generate_with_invalid_value(self):
     configuration = Configuration('/tmp', 'https://example.com')
     sut = LocalizedPathUrlGenerator(configuration)
     with self.assertRaises(ValueError):
         sut.generate(9, 'text/html')
Beispiel #3
0
 def test_generate_absolute(self, expected: str, resource: str):
     configuration = Configuration('/tmp', 'https://example.com')
     sut = LocalizedPathUrlGenerator(configuration)
     self.assertEquals(expected, sut.generate(
         resource, 'text/html', absolute=True))
Beispiel #4
0
 def test_generate_with_clean_urls(self, expected: str, resource: str):
     configuration = Configuration('/tmp', 'https://example.com')
     configuration.clean_urls = True
     sut = LocalizedPathUrlGenerator(configuration)
     self.assertEquals(expected, sut.generate(resource, 'text/html'))