def test_manifest_equality(): tree = Tree(DirectoryEntry.for_directory(temp_dir), []) expected_entries = { e.path: e for d in tree for e in d } expected_name = 'manifest/hostname/username/2013-03-18T15:33:50.122018' expected = Manifest(expected_name, expected_entries) with patch("tardis.manifest.iso8601") as iso8601: iso8601.return_value = '2013-03-18T15:33:50.122018' assert_really_equal(expected, Manifest.from_filesystem('hostname', 'username', [temp_dir])) with patch("tardis.manifest.iso8601") as iso8601: iso8601.return_value = '2013-03-24T00:00:00.000000' assert_really_not_equal(expected, Manifest.from_filesystem('hostname', 'username', [temp_dir])) assert_equal(NotImplemented, expected.__eq__(1)) assert_equal(NotImplemented, expected.__ne__(1))
def test_manifest_to_csv(): def csv_row_for(i): filename = os.path.join(temp_dir, str(i)) stat_info = StatInfo.for_file(filename) content = "This is content number {}".format(i) object_id = "data/{}/{}".format(sha1sum(str(i)), sha1sum(content)) return "{}:{}:{}".format(filename, object_id, ":".join(str(field) for field in stat_info)) manifest = Manifest.from_filesystem('hostname', 'username', [temp_dir]) with closing(StringIO()) as csvfile: manifest.to_csv(csvfile) contents = csvfile.getvalue() expected = ['"{}"'.format(manifest._name)] expected += [csv_row_for(i) for i in range(10)] assert_equals(sorted(expected), sorted(contents.splitlines()))
def test_manifest_from_filesystem_path_is_not_directory(): path = os.path.join(temp_dir, '0') Manifest.from_filesystem('hostname', 'username', [path])
def test_manifest_from_filesystem_no_path(): Manifest.from_filesystem('hostname', 'username', None)
def test_manifest_from_filesystem_no_username(): Manifest.from_filesystem('hostname', None, [temp_dir])