Пример #1
0
    def test_multiple_entries_save_load(self):
        """
        Tests creating a new mirror list file with multiple entries, saving it, and then
        loading it back from disk.
        """

        # Test Save
        mirror_list = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        mirror_list.add_entry('http://cds-01')
        mirror_list.add_entry('http://cds-02')

        mirror_list.save()

        # Verify Save
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        # Test Load
        loaded = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        loaded.load()

        # Verify Load
        self.assertEqual(2, len(loaded.entries))

        #   Make sure the entries are returned in the correct order
        self.assertEqual('http://cds-01', loaded.entries[0])
        self.assertEqual('http://cds-02', loaded.entries[1])
Пример #2
0
    def test_add_entries(self):
        """
        Tests the ability to add a list of entries in a single operation.
        """

        # Setup
        mirror_list = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        mirror_list.add_entry('http://cds-01')

        add_us = ['http://cds-02', 'http://cds-03']

        # Test
        mirror_list.add_entries(add_us)

        # Verify
        self.assertEqual(3, len(mirror_list.entries))