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_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_save_creates_new_dir(self, mock_open, mock_split, mock_exists, mock_makedirs): mock_exists.return_value = False f = ProtectedRepoListingFile("/a/nonexistant/path") f.save() mock_makedirs.assert_called_once()
def test_save_creates_new_dir(self, mock_open, mock_split, mock_exists, mock_makedirs): mock_exists.return_value = False f = ProtectedRepoListingFile("/a/nonexistant/path") f.save() mock_makedirs.assert_called_once()