Пример #1
0
    def test_RaisesErrorOnTooMany404(self):
        from httplib import BadStatusLine
        wrapper = PhillyLegistarSiteWrapper(root_url='')
        wrapper.urlopen = mock.Mock(side_effect=BadStatusLine(500))

        self.assertRaises(BadStatusLine, wrapper.check_for_new_content, 73)
        # Check that we've retried the URL 10 items
        self.assertEqual(wrapper.urlopen.call_count, 10)
Пример #2
0
    def test_RaisesErrorOnTooMany404(self):
        from httplib import BadStatusLine
        wrapper = PhillyLegistarSiteWrapper()
        wrapper.urlopen = mock.Mock(
            side_effect=BadStatusLine(500))

        self.assertRaises(BadStatusLine, wrapper.check_for_new_content, 73)
        self.assertEqual(wrapper.urlopen.call_count, 10)
Пример #3
0
    def test_ExitsSilentlyOnNoNewContent(self):
        wrapper = PhillyLegistarSiteWrapper()
        error_page = self.open_legfile('12000').read()
        wrapper.urlopen = mock.Mock(
            side_effect=lambda *a, **k: StringIO(error_page))

        wrapper.check_for_new_content(73)
        self.assertEqual(wrapper.urlopen.call_count, 10)
Пример #4
0
    def test_ExitsSilentlyOnNoNewContent(self):
        wrapper = PhillyLegistarSiteWrapper(root_url='')
        error_page = self.open_legfile('12000').read()
        wrapper.urlopen = mock.Mock(
            side_effect=lambda *a, **k: StringIO(error_page))

        wrapper.check_for_new_content(73)
        # Check that we've tried 100 additional items
        self.assertEqual(wrapper.urlopen.call_count, 100)
Пример #5
0
    def test_PdfDataIsCached(self):
        wrapper = PhillyLegistarSiteWrapper()
        wrapper.urlopen = mock.Mock(return_value=StringIO('<doc><pdf2xml></pdf2xml></doc>'))
        wrapper.extract_xml_text = mock.Mock()

        actions = [{'minutes_url': 'http://www.sample.com/file.pdf'},
                   {'minutes_url': 'http://www.sample.com/file.pdf'},
                   {'minutes_url': 'http://www.sample.com/other/file.pdf'}]
        minutes = wrapper.collect_minutes(actions)

        self.assertEqual(wrapper.urlopen.call_count, 2)
Пример #6
0
    def test_PdfDataIsCached(self):
        wrapper = PhillyLegistarSiteWrapper(root_url='')
        wrapper.urlopen = mock.Mock(
            return_value=StringIO('<doc><pdf2xml></pdf2xml></doc>'))
        wrapper.extract_xml_text = mock.Mock()

        actions = [{
            'minutes_url': 'http://www.sample.com/file.pdf'
        }, {
            'minutes_url': 'http://www.sample.com/file.pdf'
        }, {
            'minutes_url': 'http://www.sample.com/other/file.pdf'
        }]
        minutes = wrapper.collect_minutes(actions)

        self.assertEqual(wrapper.urlopen.call_count, 2)