This module contains classes and functions used for mocking and testing either the Analyzer4D software or its artifacts.

MockBuffer

class qass.tools.analyzer.testing.MockBuffer(filepath: Path | str, **kwargs)[source]

Mock buffer class that is able to parse JSON encoded files. All attributes in the JSON are added as fields in the object.

Note

Currently this only allows the mocking of header attributes

Creating a Mock Metadata Object:

# This object can either be created using the constructor
from qass.tools.analyzer.testing import MockBuffer
buffer = MockBuffer("/my/path/to/file", header_hash="0", process=1)

Loading a file:

# By writing the desired attributes to a json file
import json
from pathlib import Path

from qass.tools.analyzer.testing import MockBuffer

file = Path("testfile.json")
with open("file", "w") as f:
    json.dump({"header_hash": "0", "process": 1})
buffer = MockBuffer(file)
# this step will load the json file into the dataclass
with buffer:
    pass