コード例 #1
0
    def setUp(self, *args, **kwargs):
        yield super(TestFoursquareWeb, self).setUp(*args, **kwargs)
        self.service = FoursquareWeb(datastore=self.app.db)
        self.daemon = self.service.daemon_object()

        recorder.wrap(self.service.actually_request)
        recorder.wrap(self.daemon.actually_request)
        recorder.play()
コード例 #2
0
    def test_response_filter(self):
        ms = MockService()
        recorder.use_filters = True
        recorder.wrap(ms.actually_request)
        recorder.record()
        args = []
        kwargs = {"url": "http://example.com/year"}
        resp = yield ms.request(**kwargs)
        self.assertEqual(resp["year"], 2013)
        recorder.stop()
        recorder.save()

        resp = yield ms.request(url="http://example.com/year")
        self.assertEqual(resp["year"], 3013)
        # we must turn off filters here, or we'll get strange database errors on setup for other
        # tests
        recorder.use_filters = False
コード例 #3
0
ファイル: test_reddit.py プロジェクト: jdrago999/lightning
    def setUp(self):
        yield super(TestRedditWeb, self).setUp()
        self.service = RedditWebMock(
            datastore=self.app.db,
        )
        self.daemon = self.service.daemon_object()

        recorder.wrap(self.service.actually_request)
        recorder.wrap(self.daemon.actually_request)
        recorder.wrap(requests.request)
コード例 #4
0
ファイル: test_flickr.py プロジェクト: jdrago999/lightning
    def setUp(self, *args, **kwargs):
        yield super(TestFlickrWeb, self).setUp(*args, **kwargs)
        self.service = FlickrWeb(
            datastore=self.app.db,
        )
        self.daemon = self.service.daemon_object()

        recorder.wrap(self.service.actually_request)
        recorder.wrap(self.daemon.actually_request)
        recorder.wrap(requests.request)
コード例 #5
0
ファイル: base.py プロジェクト: jdrago999/lightning
from bs4 import BeautifulSoup
from lightning.recorder import recorder
from lightning.service.base import Profile
import logging
import os
import time
import re
import requests
from subprocess import Popen, PIPE, STDOUT
from twistedpyres import ResQ

USER_AGENT = dict(
    firefox='Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1',
)

recorder.wrap(requests.request)

class TestService(TestLightning):
    def _test_method_result_keys(self, method_name, result, expected_result=None):
        """
        This method verifies that the result value passed in matches the values that
        we expect for the given method.

        For example, we could test the method return value of profile.  This method
        will verify that all the profile keys (first_name, last_name, etc) are contained
        in the return value.

        method_name: the method to compare the result again
        result: the result to test against the expected result
        """