Datasets:

Languages:
English
ArXiv:
License:
mattdeitke commited on
Commit
baf1745
1 Parent(s): dfc948f

update tests

Browse files
Files changed (1) hide show
  1. tests/test_api.py +18 -6
tests/test_api.py CHANGED
@@ -17,8 +17,20 @@ def test_github_process_repo():
17
  fs, path = fsspec.core.url_to_fs(base_download_dir)
18
  fs.makedirs(path, exist_ok=True)
19
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
21
- # shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
22
  out = github_downloader._process_repo(
23
  repo_id="mattdeitke/objaverse-xl-test-files",
24
  fs=fs,
@@ -28,20 +40,20 @@ def test_github_process_repo():
28
  handle_found_object=None,
29
  handle_modified_object=None,
30
  handle_missing_object=None,
31
- handle_new_object=None,
32
  commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
33
  )
34
 
35
  # test that the sha256's are correct
36
- assert len(out) == 3
37
- sha256s = [x["sha256"] for x in out]
38
  for sha256 in [
39
  "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
40
  "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
41
  "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
42
  ]:
43
  assert sha256 in sha256s, f"{sha256=} not in {sha256s=}"
44
- github_urls = [x["fileIdentifier"] for x in out]
45
  for github_url in [
46
  "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
47
  "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
@@ -134,7 +146,7 @@ def test_github_handle_new_object():
134
  commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
135
  )
136
 
137
- assert len(out) == 3
138
  assert len(new_objects) == 3
139
  assert len(found_objects) == 0
140
  assert len(modified_objects) == 0
 
17
  fs, path = fsspec.core.url_to_fs(base_download_dir)
18
  fs.makedirs(path, exist_ok=True)
19
 
20
+ new_objects = []
21
+ handle_new_object = (
22
+ lambda local_path, file_identifier, sha256, metadata: new_objects.append(
23
+ dict(
24
+ local_path=local_path,
25
+ file_identifier=file_identifier,
26
+ sha256=sha256,
27
+ metadata=metadata,
28
+ )
29
+ )
30
+ )
31
+
32
  for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
33
+ shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
34
  out = github_downloader._process_repo(
35
  repo_id="mattdeitke/objaverse-xl-test-files",
36
  fs=fs,
 
40
  handle_found_object=None,
41
  handle_modified_object=None,
42
  handle_missing_object=None,
43
+ handle_new_object=handle_new_object,
44
  commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
45
  )
46
 
47
  # test that the sha256's are correct
48
+ assert len(out) == 0
49
+ sha256s = [x["sha256"] for x in new_objects]
50
  for sha256 in [
51
  "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
52
  "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
53
  "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
54
  ]:
55
  assert sha256 in sha256s, f"{sha256=} not in {sha256s=}"
56
+ github_urls = [x["file_identifier"] for x in new_objects]
57
  for github_url in [
58
  "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
59
  "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
 
146
  commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
147
  )
148
 
149
+ assert len(out) == 0
150
  assert len(new_objects) == 3
151
  assert len(found_objects) == 0
152
  assert len(modified_objects) == 0