def test_smoke(self): # Empty directory looks like an empty repository with TemporaryDirectory() as tmp: repo = SessionStorageRepository(tmp) self.assertEqual(repo.location, tmp) self.assertEqual(repo.get_storage_list(), []) self.assertEqual(list(iter(repo)), []) self.assertEqual(repo.get_last_storage(), None)
def test_get_last_storage__broken_symlink(self): # Directory with some sub-directories looks like a repository # with a bunch of sessions inside. with TemporaryDirectory() as tmp: # Create a repository without any sessions and one broken symlink repo = SessionStorageRepository(tmp) self._populate_dummy_repo(repo, [], "b0rken.session") # Get the last storage object storage = repo.get_last_storage() # Make sure it's not valid self.assertEqual(storage, None)
def test_get_last_storage(self): # Directory with some sub-directories looks like a repository # with a bunch of sessions inside. with TemporaryDirectory() as tmp: # Create a repository and some dummy data repo = SessionStorageRepository(tmp) self._populate_dummy_repo(repo) # Get the last storage object storage = repo.get_last_storage() # Check that we got session1 self.assertEqual(os.path.basename(storage.location), 'session1')
def test_get_last_storage__broken_symlink(self): # Directory with some sub-directories looks like a repository # with a bunch of sessions inside. with TemporaryDirectory() as tmp: # Create a repository without any sessions and one broken symlink repo = SessionStorageRepository(tmp) self._populate_dummy_repo(repo, [], "b0rken") # Get the last storage object storage = repo.get_last_storage() # Make sure it's not valid self.assertEqual(storage, None)
def test_get_last_storage(self): # Directory with some sub-directories looks like a repository # with a bunch of sessions inside. with TemporaryDirectory() as tmp: # Create a repository and some dummy data repo = SessionStorageRepository(tmp) self._populate_dummy_repo(repo) # Get the last storage object storage = repo.get_last_storage() # Check that we got session1 self.assertEqual( os.path.basename(storage.location), 'session1')