Debian Codegraph @

testing/mozbase/mozproxy/tests/test_recordings.py

raw
1 #!/usr/bin/env python
2 import os
3
4 import mozunit
5 from mozproxy.recordings import RecordingFile
6
7 here = os.path.dirname(__file__)
8 os.environ["MOZPROXY_DIR"] = os.path.join(here, "files")
9
10
11 def test_recording_generation(*args):
12 test_file = os.path.join(here, "files", "new_file.zip")
13 file = RecordingFile(test_file)
14 with open(file.recording_path, "w") as recording:
15 recording.write("This is a recording")
16
17 file.set_metadata("test_file", True)
18 file.generate_zip_file()
19
20 assert os.path.exists(test_file)
21 os.remove(test_file)
22 os.remove(file.recording_path)
23 os.remove(file._metadata_path)
24
25
26 def test_recording_content(*args):
27 test_file = os.path.join(here, "files", "recording.zip")
28 file = RecordingFile(test_file)
29
30 assert file.metadata("test_file") is True
31 assert os.path.exists(file.recording_path)
32 os.remove(file.recording_path)
33 os.remove(file._metadata_path)
34
35
36 if __name__ == "__main__":
37 mozunit.main(runwith="pytest")