def test_it_does_not_return_non_directories_from_local_dests(self): self.mock_os_module.listdir.return_value = [ "a_file", "another_file", "latest.snapshot", ] self.mock_os_module.path.isdir.return_value = False assert snapshotter._ls_snapshots("/home/seanh/Music") == []
def test_it_does_not_return_non_snapshot_directories_from_remote_dests( self): self.mock_run_function.return_value = ("some other directory\n" "2016-03-20T13_20_11.snapshot\n" "latest.snapshot\n") snapshots = snapshotter._ls_snapshots( "[email protected]:notes.backup") for snapshot in snapshots: assert "some other directory" not in snapshot
def test_it_returns_snapshots_from_remote_dests(self): self.mock_run_function.return_value = ("2016-03-20T13_19_25.snapshot\n" "2016-03-20T13_20_11.snapshot\n" "latest.snapshot\n") snapshots = snapshotter._ls_snapshots( "[email protected]:notes.backup") assert set(snapshots) == set([ "notes.backup/2016-03-20T13_19_25.snapshot", "notes.backup/2016-03-20T13_20_11.snapshot" ])
def test_it_does_not_return_non_snapshot_directories_from_remote_dests(self): self.mock_run_function.return_value = ( "some other directory\n" "2016-03-20T13_20_11.snapshot\n" "latest.snapshot\n" ) snapshots = snapshotter._ls_snapshots( "[email protected]:notes.backup") for snapshot in snapshots: assert "some other directory" not in snapshot
def test_it_returns_snapshots_from_local_dests(self): self.mock_os_module.listdir.return_value = [ "2016-03-20T13_19_25.snapshot", "2016-03-20T13_20_11.snapshot", "latest.snapshot", ] snapshots = snapshotter._ls_snapshots("/home/seanh/Music") assert set(snapshots) == set([ "/home/seanh/Music/2016-03-20T13_19_25.snapshot", "/home/seanh/Music/2016-03-20T13_20_11.snapshot"])
def test_it_does_not_return_non_snapshot_directories_from_local_dests(self): self.mock_os_module.listdir.return_value = [ "2016-03-20T13_19_25.snapshot", "some other directory", "2016-03-20T13_20_11.snapshot", "latest.snapshot", ] snapshots = snapshotter._ls_snapshots("/home/seanh/Music") for snapshot in snapshots: assert "some other directory" not in snapshot
def test_it_returns_snapshots_from_local_dests(self): self.mock_os_module.listdir.return_value = [ "2016-03-20T13_19_25.snapshot", "2016-03-20T13_20_11.snapshot", "latest.snapshot", ] snapshots = snapshotter._ls_snapshots("/home/seanh/Music") assert set(snapshots) == set([ "/home/seanh/Music/2016-03-20T13_19_25.snapshot", "/home/seanh/Music/2016-03-20T13_20_11.snapshot" ])
def test_it_does_not_return_non_snapshot_directories_from_local_dests( self): self.mock_os_module.listdir.return_value = [ "2016-03-20T13_19_25.snapshot", "some other directory", "2016-03-20T13_20_11.snapshot", "latest.snapshot", ] snapshots = snapshotter._ls_snapshots("/home/seanh/Music") for snapshot in snapshots: assert "some other directory" not in snapshot
def test_it_returns_snapshots_from_remote_dests(self): self.mock_run_function.return_value = ( "2016-03-20T13_19_25.snapshot\n" "2016-03-20T13_20_11.snapshot\n" "latest.snapshot\n" ) snapshots = snapshotter._ls_snapshots( "[email protected]:notes.backup") assert set(snapshots) == set([ "notes.backup/2016-03-20T13_19_25.snapshot", "notes.backup/2016-03-20T13_20_11.snapshot"])
def test_it_returns_snapshots_in_oldest_first_order(self): self.mock_os_module.listdir.return_value = [ "2016-03-20T13_19_25.snapshot", "2016-03-20T13_20_11.snapshot", "2016-03-20T13_21_11.snapshot", "latest.snapshot", ] snapshots = snapshotter._ls_snapshots("/home/seanh/Music") assert snapshots == [ "/home/seanh/Music/2016-03-20T13_19_25.snapshot", "/home/seanh/Music/2016-03-20T13_20_11.snapshot", "/home/seanh/Music/2016-03-20T13_21_11.snapshot", ]
def test_it_calls_os_listdir_correctly(self): snapshots = snapshotter._ls_snapshots("/home/seanh/Music") self.mock_os_module.listdir.assert_called_once_with( "/home/seanh/Music")
def test_it_calls_run_correctly_when_dest_is_remote(self): snapshotter._ls_snapshots("[email protected]:notes.backup") self.mock_run_function.assert_called_once_with( ['ssh', '[email protected]', 'ls', 'notes.backup'])