예제 #1
0
    def test_fetch(self):
        """Test whether it fetches and parses messages"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path)
        messages = [m for m in backend.fetch()]

        expected = [('<CACRHdMaObu7Dc0FWTWEesvRCzUNDG=7oA7KFqAgtOs_UKjb3Og@mail.gmail.com>',
                     '57f2a6c029df5e5f1b1698aa7f9d430613a87e00', 1447532968.0, 0),
                    ('<*****@*****.**>',
                     '734ecfbb6fe751b372d88bdd8b5ab27b2774e389', 1447627429.0, 1),
                    ('<[email protected]>',
                     'ec9de08e0904e10c64c225d1ae453a06afd1d2e2', 1448107551.0, 2),
                    ('<*****@*****.**>',
                     '7443147416e72a109dc4c34f6933c019619135da', 1448742330.0, 3),
                    ('<*****@*****.**>',
                     '22d57bd93e0696392fbd8edde96e60116aca9e06', 1457025635.0, 4),
                    ('<*****@*****.**>',
                     '50501282d7c3178e946b46d5e557924d08d11df2', 1460624816.0, 5),
                    ('<[email protected]>',
                     '40feb0bd9206ffc325cec9ede16f6c6638c93b58', 1461428336.0, 6),
                    ('<*****@*****.**>',
                     'b022328e2fe72985e543712cf4f359e9daa80349', 1461621607.0, 7)]

        self.assertEqual(len(messages), 8)

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['Message-ID'], expected[x][0])
            self.assertEqual(message['origin'], GMANE_MYLIST_URL)
            self.assertEqual(message['uuid'], expected[x][1])
            self.assertEqual(message['updated_on'], expected[x][2])
            self.assertEqual(message['offset'], expected[x][3])
            self.assertEqual(message['category'], 'message')
예제 #2
0
    def test_fetch_empty(self):
        """Test whether it works when there are not any messages"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path)
        messages = [m for m in backend.fetch(offset=6000)]

        self.assertListEqual(messages, [])
예제 #3
0
    def test_fetch_empty(self):
        """Test whether it works when there are not any messages"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path)
        messages = [m for m in backend.fetch(offset=6000)]

        self.assertListEqual(messages, [])
예제 #4
0
    def test_initialization(self):
        """Test whether attributes are initializated"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path, origin='test')

        self.assertEqual(backend.url, GMANE_MYLIST_URL)
        self.assertEqual(backend.uri, GMANE_MYLIST_URL)
        self.assertEqual(backend.dirpath, self.tmp_path)
        self.assertEqual(backend.origin, 'test')

        # When origin is empty or None it will be set to
        # the value of the Gmane mailing list
        backend = Gmane('*****@*****.**', self.tmp_path)
        self.assertEqual(backend.origin, GMANE_MYLIST_URL)

        backend = Gmane('*****@*****.**', self.tmp_path, origin='')
        self.assertEqual(backend.origin, GMANE_MYLIST_URL)
예제 #5
0
    def test_fetch_from_offset(self):
        """Test whether it fetches and parses messages from the given offset"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path)
        messages = [m for m in backend.fetch(offset=4000)]

        # For this test, only one mbox should be downloaded because the
        # offset starts at 0
        mboxes_downloaded = []

        for root, _, files in os.walk(self.tmp_path):
            for filename in sorted(files):
                location = os.path.join(root, filename)
                mboxes_downloaded.append(location)

        self.assertListEqual(mboxes_downloaded,
                             [os.path.join(self.tmp_path, '4000')])

        expected = [
            ('<*****@*****.**>',
             '50501282d7c3178e946b46d5e557924d08d11df2', 1460624816.0, 4000),
            ('<[email protected]>',
             '40feb0bd9206ffc325cec9ede16f6c6638c93b58', 1461428336.0, 4001),
            ('<*****@*****.**>',
             'b022328e2fe72985e543712cf4f359e9daa80349', 1461621607.0, 4002)
        ]

        self.assertEqual(len(messages), 3)

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['Message-ID'], expected[x][0])
            self.assertEqual(message['origin'], GMANE_MYLIST_URL)
            self.assertEqual(message['uuid'], expected[x][1])
            self.assertEqual(message['updated_on'], expected[x][2])
            self.assertEqual(message['offset'], expected[x][3])
            self.assertEqual(message['category'], 'message')
            self.assertEqual(message['tag'], GMANE_MYLIST_URL)
예제 #6
0
    def test_fetch_from_offset(self):
        """Test whether it fetches and parses messages from the given offset"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path)
        messages = [m for m in backend.fetch(offset=4000)]

        # For this test, only one mbox should be downloaded because the
        # offset starts at 0
        mboxes_downloaded = []

        for root, _, files in os.walk(self.tmp_path):
            for filename in sorted(files):
                location = os.path.join(root, filename)
                mboxes_downloaded.append(location)

        self.assertListEqual(mboxes_downloaded,
                             [os.path.join(self.tmp_path, '4000')])

        expected = [('<*****@*****.**>',
                     '50501282d7c3178e946b46d5e557924d08d11df2', 1460624816.0, 4000),
                    ('<[email protected]>',
                     '40feb0bd9206ffc325cec9ede16f6c6638c93b58', 1461428336.0, 4001),
                    ('<*****@*****.**>',
                     'b022328e2fe72985e543712cf4f359e9daa80349', 1461621607.0, 4002)]

        self.assertEqual(len(messages), 3)

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['Message-ID'], expected[x][0])
            self.assertEqual(message['origin'], GMANE_MYLIST_URL)
            self.assertEqual(message['uuid'], expected[x][1])
            self.assertEqual(message['updated_on'], expected[x][2])
            self.assertEqual(message['offset'], expected[x][3])
            self.assertEqual(message['category'], 'message')
            self.assertEqual(message['tag'], GMANE_MYLIST_URL)
예제 #7
0
    def test_fetch(self):
        """Test whether it fetches and parses messages"""

        setup_http_server()

        backend = Gmane('*****@*****.**', self.tmp_path)
        messages = [m for m in backend.fetch()]

        expected = [
            ('<CACRHdMaObu7Dc0FWTWEesvRCzUNDG=7oA7KFqAgtOs_UKjb3Og@mail.gmail.com>',
             '57f2a6c029df5e5f1b1698aa7f9d430613a87e00', 1447532968.0, 0),
            ('<*****@*****.**>',
             '734ecfbb6fe751b372d88bdd8b5ab27b2774e389', 1447627429.0, 1),
            ('<[email protected]>',
             'ec9de08e0904e10c64c225d1ae453a06afd1d2e2', 1448107551.0, 2),
            ('<*****@*****.**>',
             '7443147416e72a109dc4c34f6933c019619135da', 1448742330.0, 3),
            ('<*****@*****.**>',
             '22d57bd93e0696392fbd8edde96e60116aca9e06', 1457025635.0, 4),
            ('<*****@*****.**>',
             '50501282d7c3178e946b46d5e557924d08d11df2', 1460624816.0, 5),
            ('<[email protected]>',
             '40feb0bd9206ffc325cec9ede16f6c6638c93b58', 1461428336.0, 6),
            ('<*****@*****.**>',
             'b022328e2fe72985e543712cf4f359e9daa80349', 1461621607.0, 7)
        ]

        self.assertEqual(len(messages), 8)

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['Message-ID'], expected[x][0])
            self.assertEqual(message['origin'], GMANE_MYLIST_URL)
            self.assertEqual(message['uuid'], expected[x][1])
            self.assertEqual(message['updated_on'], expected[x][2])
            self.assertEqual(message['offset'], expected[x][3])
            self.assertEqual(message['category'], 'message')
            self.assertEqual(message['tag'], GMANE_MYLIST_URL)
예제 #8
0
    def test_has_resuming(self):
        """Test if it returns True when has_resuming is called"""

        self.assertEqual(Gmane.has_resuming(), True)
예제 #9
0
    def test_has_caching(self):
        """Test if it returns False when has_caching is called"""

        self.assertEqual(Gmane.has_caching(), False)
예제 #10
0
    def test_has_resuming(self):
        """Test if it returns True when has_resuming is called"""

        self.assertEqual(Gmane.has_resuming(), True)
예제 #11
0
    def test_has_caching(self):
        """Test if it returns False when has_caching is called"""

        self.assertEqual(Gmane.has_caching(), False)