示例#1
0
    def setUp(self):
        yield self._start_container()
        services = [{'name':'fetcher', 'module':'ion.services.dm.fetcher',
                    'class': 'FetcherService'},]
        sup = yield self._spawn_processes(services)

        self.fc = FetcherClient(proc=sup)
示例#2
0
class FetcherTest(IonTestCase):
    @defer.inlineCallbacks
    def setUp(self):
        yield self._start_container()
        services = [{'name':'fetcher', 'module':'ion.services.dm.fetcher',
                    'class': 'FetcherService'},]
        sup = yield self._spawn_processes(services)

        self.fc = FetcherClient(proc=sup)

    @defer.inlineCallbacks
    def tearDown(self):
        yield self._stop_container()

    @defer.inlineCallbacks
    def _get_page(self, src_url):
        logging.debug('sending request for "%s"...' % src_url)
        res = yield self.fc.get_url(src_url)
        msg = res['value']
        defer.returnValue(msg)

    @defer.inlineCallbacks
    def test_single_get(self):
        """
        Simplest test, fetch a fixed local page.
        @note Contenst of same in /var/www/tmp on amoeba.ucsd.edu
        """
        res = yield self._get_page('http://amoeba.ucsd.edu/tmp/test1.txt')
        msg = res.strip()
        self.failUnlessEqual(msg, 'Now is the time for all good men to come to the aid of their country.')

    @defer.inlineCallbacks
    def test_404(self):
        try:
            d = yield self._get_page('http://ooici.net/404-fer-sure')
            self.fail('Should have gotten an exception for 404 error!')
        except ValueError, e:
            pass