Skip to content

Commit

Permalink
Review updates and Functional test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
riya-17 committed Jun 23, 2023
1 parent e45fb3c commit b542bc3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
12 changes: 1 addition & 11 deletions lib/pbench/server/api/resources/intake_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
ApiSchema,
)
import pbench.server.auth.auth as Auth
from pbench.server.cache_manager import (
BadDirpath,
CacheManager,
DuplicateTarball,
MetadataError,
)
from pbench.server.cache_manager import CacheManager, DuplicateTarball, MetadataError
from pbench.server.database.models.audit import (
Audit,
AuditReason,
Expand Down Expand Up @@ -383,11 +378,6 @@ def _intake(
# Move the files to their final location
try:
tarball = cache_m.create(tar_full_path)
except BadDirpath as exc:
raise APIAbort(
HTTPStatus.BAD_REQUEST,
exc,
) from exc
except DuplicateTarball as exc:
raise APIAbort(
HTTPStatus.BAD_REQUEST,
Expand Down
2 changes: 1 addition & 1 deletion lib/pbench/server/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def _get_metadata(tarball_path: Path) -> Optional[JSONOBJECT]:
return None
else:
metadata_log = MetadataLog()
metadata_log.read_file(data)
metadata_log.read_file(e.decode() for e in data)
metadata = {s: dict(metadata_log.items(s)) for s in metadata_log.sections()}
return metadata

Expand Down
4 changes: 2 additions & 2 deletions lib/pbench/test/unit/server/test_cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,8 @@ def test_filestream(
with monkeypatch.context() as m:
m.setattr(Tarball, "__init__", TestCacheManager.MockTarball.__init__)
m.setattr(Controller, "__init__", TestCacheManager.MockController.__init__)
m.setattr(Tarball, "extract", lambda _s, _t: exp_stream)
m.setattr(Path, "open", lambda _s, _m: exp_stream)
m.setattr(Tarball, "extract", lambda _t, _p: exp_stream)
m.setattr(Path, "open", lambda _s, _m="rb": exp_stream)
tb = Tarball(tar, Controller(Path("/mock/archive"), cache, None))
tar_dir = TestCacheManager.MockController.generate_test_result_tree(
tmp_path, "dir_name"
Expand Down
7 changes: 5 additions & 2 deletions lib/pbench/test/unit/server/test_datasets_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self, path: Path, controller: Controller):
self.unpacked = None

def filestream(self, target):
print("FS")
info = {
"name": "f1.json",
"type": CacheType.FILE,
Expand Down Expand Up @@ -109,8 +108,12 @@ def test_not_a_file(self, query_get_as, monkeypatch):
}

def test_dataset_in_given_path(self, query_get_as, monkeypatch):
class MockBytesIO(io.BytesIO):
def close(self):
super().close()

mock_args: Optional[tuple[Path, dict[str, Any]]] = None
exp_stream = io.BytesIO(b"file_as_a_byte_stream")
exp_stream = MockBytesIO(b"file_as_a_byte_stream")
filestream_dict = {
"name": "f1.json",
"type": CacheType.FILE,
Expand Down

0 comments on commit b542bc3

Please sign in to comment.