Пример #1
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?flic.kr"
     self.xml_pattern = re.compile(
         r'''label="Original"\s
                                   width="(.*)"\s  # The width of the image
                                   height="(.*)"\s # The height of the image
                                   source="(.*)"\s # Image's source
                                   url="(.*)"\s    # The URL
                                   media="(.*)"''', re.VERBOSE)
     self.resp_pattern = re.compile('/photos/(.*)/(.*)/')
Пример #2
0
class TestPreviewBase:
    @classmethod
    @pytest.fixture(autouse=True)
    def setup_class(self, monkeypatch):
        self.preview = PreviewMediaService()

    def test_do_service(self):
        with pytest.raises(NotImplementedError):
            self.preview.do_service('http://example.org')

    def test_get_content_from_url(self, monkeypatch):
        monkeypatch.setattr(requests, 'get', lambda x: DummyResponse('loremipsum'))

        response = self.preview._get_content_from_url('http://example.com')
        assert response == 'loremipsum'

    def test_get_id_from_url(self):
        response = self.preview._get_id_from_url('http://example.org/1')
        assert response == '1'
Пример #3
0
class TestPreviewBase:
    @classmethod
    @pytest.fixture(autouse=True)
    def setup_class(self, monkeypatch):
        self.preview = PreviewMediaService()

    def test_do_service(self):
        with pytest.raises(NotImplementedError):
            self.preview.do_service('http://example.org')

    def test_get_content_from_url(self, monkeypatch):
        monkeypatch.setattr(requests, 'get',
                            lambda x: DummyResponse('loremipsum'))

        response = self.preview._get_content_from_url('http://example.com')
        assert response == 'loremipsum'

    def test_get_id_from_url(self):
        response = self.preview._get_id_from_url('http://example.org/1')
        assert response == '1'
Пример #4
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?lockerz.com"
Пример #5
0
 def setup_class(self, monkeypatch):
     self.preview = PreviewMediaService()
Пример #6
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?twitpic.com"
Пример #7
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?(twimg.com|pic.twitter.com)"
Пример #8
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?via.me"
Пример #9
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?via.me"
Пример #10
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?twitpic.com"
Пример #11
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?(twimg.com|pic.twitter.com)"
Пример #12
0
 def __init__(self):
     PreviewMediaService.__init__(self)
     self.url_pattern = "(http(s)?://)?lockerz.com"
Пример #13
0
 def setup_class(self, monkeypatch):
     self.preview = PreviewMediaService()