Example #1
0
    def test_fetch_empty(self):
        """Test whether it does nothing when a response is empty"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        archives = gmls.fetch(offset=6000)
        self.assertEqual(len(archives), 0)

        mboxes = gmls.mboxes
        self.assertEqual(len(mboxes), 0)
Example #2
0
    def test_fetch_empty(self):
        """Test whether it does nothing when a response is empty"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        archives = gmls.fetch(offset=6000)
        self.assertEqual(len(archives), 0)

        mboxes = gmls.mboxes
        self.assertEqual(len(mboxes), 0)
Example #3
0
    def test_fetch_from_offset(self):
        """Test whether it fetches a set of messages from a given offset"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        archives = gmls.fetch(offset=4000)
        self.assertEqual(len(archives), 1)
        self.assertEqual(archives[0][0], 4000)
        self.assertEqual(archives[0][1], os.path.join(self.tmp_path, '4000'))

        mboxes = gmls.mboxes
        self.assertEqual(len(mboxes), 1)
        self.assertEqual(mboxes[0].filepath, os.path.join(self.tmp_path, '4000'))
Example #4
0
    def test_fetch_from_offset(self):
        """Test whether it fetches a set of messages from a given offset"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        archives = gmls.fetch(offset=4000)
        self.assertEqual(len(archives), 1)
        self.assertEqual(archives[0][0], 4000)
        self.assertEqual(archives[0][1], os.path.join(self.tmp_path, '4000'))

        mboxes = gmls.mboxes
        self.assertEqual(len(mboxes), 1)
        self.assertEqual(mboxes[0].filepath,
                         os.path.join(self.tmp_path, '4000'))
Example #5
0
    def test_init_url_not_found(self):
        """Test whether it raises an exception when a mailing list is not found"""

        httpretty.register_uri(httpretty.GET,
                               GMANE_INVALID_LIST_URL,
                               status=200,
                               body="No such list")

        with self.assertRaises(RepositoryError):
            _ = GmaneMailingList('*****@*****.**', self.tmp_path)
Example #6
0
    def test_init(self):
        """Test if the mailing list values were initialized"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)
        self.assertIsInstance(gmls, MailingList)
        self.assertEqual(gmls.uri, GMANE_MYLIST_URL)
        self.assertEqual(gmls.dirpath, self.tmp_path)
        self.assertEqual(gmls.url, GMANE_MYLIST_URL)
Example #7
0
    def test_fetch(self):
        """Test whether it fetches a set of messages"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        archives = gmls.fetch()
        self.assertEqual(len(archives), 3)
        self.assertEqual(archives[0][0], 0)
        self.assertEqual(archives[0][1], os.path.join(self.tmp_path, '0'))
        self.assertEqual(archives[1][0], 2000)
        self.assertEqual(archives[1][1], os.path.join(self.tmp_path, '2000'))
        self.assertEqual(archives[2][0], 4000)
        self.assertEqual(archives[2][1], os.path.join(self.tmp_path, '4000'))

        mboxes = gmls.mboxes
        self.assertEqual(len(mboxes), 3)
        self.assertEqual(mboxes[0].filepath, os.path.join(self.tmp_path, '0'))
        self.assertEqual(mboxes[1].filepath, os.path.join(self.tmp_path, '2000'))
        self.assertEqual(mboxes[2].filepath, os.path.join(self.tmp_path, '4000'))
Example #8
0
    def test_fetch(self):
        """Test whether it fetches a set of messages"""

        setup_http_server()

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        archives = gmls.fetch()
        self.assertEqual(len(archives), 3)
        self.assertEqual(archives[0][0], 0)
        self.assertEqual(archives[0][1], os.path.join(self.tmp_path, '0'))
        self.assertEqual(archives[1][0], 2000)
        self.assertEqual(archives[1][1], os.path.join(self.tmp_path, '2000'))
        self.assertEqual(archives[2][0], 4000)
        self.assertEqual(archives[2][1], os.path.join(self.tmp_path, '4000'))

        mboxes = gmls.mboxes
        self.assertEqual(len(mboxes), 3)
        self.assertEqual(mboxes[0].filepath, os.path.join(self.tmp_path, '0'))
        self.assertEqual(mboxes[1].filepath,
                         os.path.join(self.tmp_path, '2000'))
        self.assertEqual(mboxes[2].filepath,
                         os.path.join(self.tmp_path, '4000'))
Example #9
0
    def test_mboxes(self):
        """Test whether it returns the mboxes ordered by the offset on their filenames"""

        setup_http_server()

        # Simulate the fetch process copying the files
        shutil.copy('data/gmane_messages.mbox',
                    os.path.join(self.tmp_path, '0'))
        shutil.copy('data/gmane_messages_2000.mbox',
                    os.path.join(self.tmp_path, '2000'))
        shutil.copy('data/gmane_messages_4000.mbox',
                    os.path.join(self.tmp_path, '4000'))
        shutil.copy('data/gmane_messages_empty.mbox',
                    os.path.join(self.tmp_path, 'gmane_messages_empty.mbox'))

        gmls = GmaneMailingList('*****@*****.**', self.tmp_path)

        mboxes = gmls.mboxes
        self.assertEqual(mboxes[0].filepath, os.path.join(self.tmp_path, '0'))
        self.assertEqual(mboxes[1].filepath,
                         os.path.join(self.tmp_path, '2000'))
        self.assertEqual(mboxes[2].filepath,
                         os.path.join(self.tmp_path, '4000'))