Exemplo n.º 1
0
 def get_cleaned_sites(self):
     """
     Attribute-caches the sites/regexes returned by
     `oembed.utils.cleaned_sites`
     """
     if not getattr(self, '_clean_sites', None):
         self._clean_sites = cleaned_sites()
     return self._clean_sites
 def get_cleaned_sites(self):
     """
     Attribute-caches the sites/regexes returned by
     `oembed.utils.cleaned_sites`
     """
     if not getattr(self, '_clean_sites', None):
         self._clean_sites = cleaned_sites()
     return self._clean_sites
Exemplo n.º 3
0
 def test_cleaned_sites(self):
     sites = Site.objects.all()
     cleaned = cleaned_sites()
     example = cleaned[1] # example site
     self.assertEquals(example[1], 'example.com')
     self.assertEquals(example[2], 'http://example.com')
     self.assertEquals(example[0], 'https?:\/\/(?:www[^\.]*\.)?example.com')
     
     www2_site = Site.objects.create(name='Test Site', domain='www2.testsite.com')
     mobile_site = Site.objects.create(name='Mobile Site', domain='m.testsite.com')
     
     cleaned = cleaned_sites()
     self.assertEquals(cleaned[www2_site.pk][1], 'Test Site')
     self.assertEquals(cleaned[www2_site.pk][2], 'http://www2.testsite.com')
     self.assertEquals(cleaned[www2_site.pk][0], 'https?:\/\/(?:www[^\.]*\.)?testsite.com')
     
     self.assertEquals(cleaned[mobile_site.pk][1], 'Mobile Site')
     self.assertEquals(cleaned[mobile_site.pk][2], 'http://m.testsite.com')
     self.assertEquals(cleaned[mobile_site.pk][0], 'https?:\/\/(?:www[^\.]*\.)?m.testsite.com')
Exemplo n.º 4
0
 def test_cleaned_sites(self):
     sites = Site.objects.all()
     cleaned = cleaned_sites()
     example = cleaned[1] # example site
     self.assertEquals(example[1], 'example.com')
     self.assertEquals(example[2], 'http://example.com')
     self.assertEquals(example[0], 'https?:\/\/(?:www[^\.]*\.)?example.com')
     
     www2_site = Site.objects.create(name='Test Site', domain='www2.testsite.com')
     mobile_site = Site.objects.create(name='Mobile Site', domain='m.testsite.com')
     
     cleaned = cleaned_sites()
     self.assertEquals(cleaned[www2_site.pk][1], 'Test Site')
     self.assertEquals(cleaned[www2_site.pk][2], 'http://www2.testsite.com')
     self.assertEquals(cleaned[www2_site.pk][0], 'https?:\/\/(?:www[^\.]*\.)?testsite.com')
     
     self.assertEquals(cleaned[mobile_site.pk][1], 'Mobile Site')
     self.assertEquals(cleaned[mobile_site.pk][2], 'http://m.testsite.com')
     self.assertEquals(cleaned[mobile_site.pk][0], 'https?:\/\/(?:www[^\.]*\.)?m.testsite.com')