def test_save_load_delete_with_repos(self):
        """
        Tests saving, reloading, and then deleting the listing file.
        """

        # Test Save
        f = ProtectedRepoListingFile(TEST_FILE)
        f.add_protected_repo_path('foo', 'repo1')
        f.save()

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

        # Test Load
        f = ProtectedRepoListingFile(TEST_FILE)
        f.load()

        # Verify Load
        self.assertEqual(1, len(f.listings))
        self.assertTrue('foo' in f.listings)
        self.assertEqual('repo1', f.listings['foo'])

        # Test Delete
        f.delete()

        # Verify Delete
        self.assertTrue(not os.path.exists(TEST_FILE))
    def test_remove_non_existent(self):
        """
        Tests removing a path that isn't in the file does not throw an error.
        """

        # Setup
        f = ProtectedRepoListingFile(TEST_FILE)
        f.add_protected_repo_path('foo', 'repo1')

        self.assertEqual(1, len(f.listings))

        # Test
        f.remove_protected_repo_path('bar') # should not error

        # Verify
        self.assertEqual(1, len(f.listings))
    def test_remove_repo_path(self):
        """
        Tests removing a repo path successfully removes it from the listings.
        """

        # Setup
        f = ProtectedRepoListingFile(TEST_FILE)
        f.add_protected_repo_path('foo', 'repo1')

        self.assertEqual(1, len(f.listings))

        # Test
        f.remove_protected_repo_path('foo')

        # Verify
        self.assertEqual(0, len(f.listings))