def test_eq_ignore_previous() -> None: """Ignore previous in Snapshot equality.""" zero = Snapshot(filesystem=filesystem(""), name="", previous=None, timestamp=0) previous = Snapshot(filesystem=filesystem(""), name="", previous=zero, timestamp=0) assert zero == previous
def test_empty_locals(snapshots: List[Snapshot]) -> None: """Generate with empty locals.""" snapshots_by_fs = { k: list(v) for (k, v) in itertools.groupby( sorted(snapshots, key=operator.attrgetter("filesystem")), key=operator.attrgetter("filesystem"), ) } result = generate(filesystem(""), {}, snapshots_by_fs) assert len([t for t in result if t.action == Action.DESTROY]) == len(snapshots_by_fs) + sum( map(len, snapshots_by_fs.values()), ) assert all(t.action == Action.DESTROY for t in result)
def test_empty_remotes(snapshots: List[Snapshot]) -> None: """Generate with empty remotes.""" snapshots_by_fs = { k: list(v) for (k, v) in itertools.groupby( sorted(snapshots, key=operator.attrgetter("filesystem")), key=operator.attrgetter("filesystem"), ) } result = generate(filesystem(""), snapshots_by_fs, {}) assert len([t for t in result if t.action == Action.CREATE and t.snapshot is None]) == len(snapshots_by_fs) assert len([t for t in result if t.action == Action.SEND and t.snapshot is not None]) == sum( map(len, snapshots_by_fs.values()), )
def test_no_tasks() -> None: """generate(Any, {}, {}) == [].""" assert [] == generate(filesystem("pool/filesystem"), {}, {})