Exemplo n.º 1
0
    def test_parseInfoFile(self):
        @stringioify
        def mocked_urlopener(url):
            if 'ONE' in url:
                return 'BUILDID=123'
            if 'TWO' in url:
                return 'BUILDID=123\nbuildID=456'
            if 'THREE' in url:
                return '123\nhttp://hg.mozilla.org/123'
            if 'FOUR' in url:
                return ('123\nhttp://hg.mozilla.org/123\n'
                        'http://git.mozilla.org/123')
            raise NotImplementedError(url)
        self.urllib2.side_effect = mocked_urlopener

        self.assertEqual(
            ftpscraper.parseInfoFile('ONE'),
            {'BUILDID': '123'}
        )
        self.assertEqual(
            ftpscraper.parseInfoFile('TWO'),
            {'BUILDID': '123',
             'buildID': '456'}
        )
        self.assertEqual(
            ftpscraper.parseInfoFile('THREE', nightly=True),
            {'buildID': '123',
             'rev': 'http://hg.mozilla.org/123'}
        )
        self.assertEqual(
            ftpscraper.parseInfoFile('FOUR', nightly=True),
            {'buildID': '123',
             'rev': 'http://hg.mozilla.org/123',
             'altrev': 'http://git.mozilla.org/123'}
        )
Exemplo n.º 2
0
    def test_parseInfoFile(self):
        @stringioify
        def mocked_urlopener(url):
            if 'ONE' in url:
                return 'BUILDID=123'
            if 'TWO' in url:
                return 'BUILDID=123\nbuildID=456'
            if 'THREE' in url:
                return '123\nhttp://hg.mozilla.org/123'
            if 'FOUR' in url:
                return ('123\nhttp://hg.mozilla.org/123\n'
                        'http://git.mozilla.org/123')
            raise NotImplementedError(url)
        self.urllib2.side_effect = mocked_urlopener

        self.assertEqual(
            ftpscraper.parseInfoFile('ONE'),
            {'BUILDID': '123'}
        )
        self.assertEqual(
            ftpscraper.parseInfoFile('TWO'),
            {'BUILDID': '123',
             'buildID': '456'}
        )
        self.assertEqual(
            ftpscraper.parseInfoFile('THREE', nightly=True),
            {'buildID': '123',
             'rev': 'http://hg.mozilla.org/123'}
        )
        self.assertEqual(
            ftpscraper.parseInfoFile('FOUR', nightly=True),
            {'buildID': '123',
             'rev': 'http://hg.mozilla.org/123',
             'altrev': 'http://git.mozilla.org/123'}
        )
Exemplo n.º 3
0
    def test_parseInfoFile(self):
        @stringioify
        def mocked_urlopener(url):
            if "ONE" in url:
                return "BUILDID=123"
            if "TWO" in url:
                return "BUILDID=123\nbuildID=456"
            if "THREE" in url:
                return "123\nhttp://hg.mozilla.org/123"
            if "FOUR" in url:
                return "123\nhttp://hg.mozilla.org/123\n" "http://git.mozilla.org/123"
            if "FIVE" in url:
                return '{"buildid": "20130309070203", ' '"update_channel": "nightly", "version": "18.0"}'
            raise NotImplementedError(url)

        self.urllib2.side_effect = mocked_urlopener

        self.assertEqual(ftpscraper.parseInfoFile("ONE"), ({"BUILDID": "123"}, []))
        self.assertEqual(ftpscraper.parseInfoFile("TWO"), ({"BUILDID": "123", "buildID": "456"}, []))
        self.assertEqual(
            ftpscraper.parseInfoFile("THREE", nightly=True),
            ({"buildID": "123", "rev": "http://hg.mozilla.org/123"}, []),
        )
        self.assertEqual(
            ftpscraper.parseInfoFile("FOUR", nightly=True),
            ({"buildID": "123", "rev": "http://hg.mozilla.org/123", "altrev": "http://git.mozilla.org/123"}, []),
        )
        self.assertEqual(
            ftpscraper.parseB2GFile("FIVE", nightly=True),
            ({"buildid": "20130309070203", "update_channel": "nightly", "version": "18.0", "build_type": "nightly"}),
        )
Exemplo n.º 4
0
    def test_parseInfoFile_with_bad_lines(self):
        @stringioify
        def mocked_urlopener(url):
            if 'ONE' in url:
                return 'BUILDID'
            if 'TWO' in url:
                return 'BUILDID=123\nbuildID'
            raise NotImplementedError(url)

        self.urllib2.side_effect = mocked_urlopener

        eq_(ftpscraper.parseInfoFile('ONE'), ({}, ['BUILDID']))

        eq_(ftpscraper.parseInfoFile('TWO'), ({'BUILDID': '123'}, ['buildID']))
Exemplo n.º 5
0
    def test_parseInfoFile_with_bad_lines(self):
        @stringioify
        def mocked_urlopener(url):
            if "ONE" in url:
                return "BUILDID"
            if "TWO" in url:
                return "BUILDID=123\nbuildID"
            raise NotImplementedError(url)

        self.urllib2.side_effect = mocked_urlopener

        self.assertEqual(ftpscraper.parseInfoFile("ONE"), ({}, ["BUILDID"]))

        self.assertEqual(ftpscraper.parseInfoFile("TWO"), ({"BUILDID": "123"}, ["buildID"]))
Exemplo n.º 6
0
    def test_parseInfoFile_with_page_not_found(self):
        @stringioify
        def mocked_urlopener(url):
            raise urllib2.HTTPError(url, 404, "Not Found", {}, None)

        self.urllib2.side_effect = mocked_urlopener

        self.assertEqual(ftpscraper.parseInfoFile('ONE'), ({}, []))
Exemplo n.º 7
0
    def test_parseInfoFile(self):
        @stringioify
        def mocked_urlopener(url):
            if 'ONE' in url:
                return 'BUILDID=123'
            if 'TWO' in url:
                return 'BUILDID=123\nbuildID=456'
            if 'THREE' in url:
                return '123\nhttp://hg.mozilla.org/123'
            if 'FOUR' in url:
                return ('123\nhttp://hg.mozilla.org/123\n'
                        'http://git.mozilla.org/123')
            if 'FIVE' in url:
                return (
                    '{"buildid": "20130309070203", '
                    '"update_channel": "nightly", "version": "18.0"}'
                )
            raise NotImplementedError(url)
        self.urllib2.side_effect = mocked_urlopener

        eq_(
            ftpscraper.parseInfoFile('ONE'),
            ({'BUILDID': '123'}, [])
        )
        eq_(
            ftpscraper.parseInfoFile('TWO'),
            ({'BUILDID': '123',
              'buildID': '456'}, [])
        )
        eq_(
            ftpscraper.parseInfoFile('THREE', nightly=True),
            ({'buildID': '123',
              'rev': 'http://hg.mozilla.org/123'}, [])
        )
        eq_(
            ftpscraper.parseInfoFile('FOUR', nightly=True),
            ({'buildID': '123',
              'rev': 'http://hg.mozilla.org/123',
              'altrev': 'http://git.mozilla.org/123'}, [])
        )
        eq_(
            ftpscraper.parseB2GFile('FIVE', nightly=True),
            ({"buildid": "20130309070203",
              "update_channel": "nightly",
              "version": "18.0",
              'build_type': 'nightly'}))
Exemplo n.º 8
0
    def test_parseInfoFile_with_bad_lines(self):
        @stringioify
        def mocked_urlopener(url):
            if 'ONE' in url:
                return 'BUILDID'
            if 'TWO' in url:
                return 'BUILDID=123\nbuildID'
            raise NotImplementedError(url)
        self.urllib2.side_effect = mocked_urlopener

        eq_(
            ftpscraper.parseInfoFile('ONE'),
            ({}, ['BUILDID'])
        )

        eq_(
            ftpscraper.parseInfoFile('TWO'),
            ({'BUILDID': '123'}, ['buildID'])
        )
Exemplo n.º 9
0
    def test_parseInfoFile_with_page_not_found(self):

        @stringioify
        def mocked_urlopener(url):
            raise urllib2.HTTPError(url, 404, "Not Found", {}, None)

        self.urllib2.side_effect = mocked_urlopener

        eq_(
            ftpscraper.parseInfoFile('ONE'),
            ({}, [])
        )