summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/wave/utils/serializer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/tools/wave/utils/serializer.py
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/tools/wave/utils/serializer.py')
-rw-r--r--testing/web-platform/tests/tools/wave/utils/serializer.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/wave/utils/serializer.py b/testing/web-platform/tests/tools/wave/utils/serializer.py
new file mode 100644
index 0000000000..995365081d
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/utils/serializer.py
@@ -0,0 +1,47 @@
+# mypy: allow-untyped-defs
+
+from datetime import datetime
+
+
+def serialize_session(session):
+ return {
+ "token": session.token,
+ "types": session.test_types,
+ "user_agent": session.user_agent,
+ "labels": session.labels,
+ "timeouts": session.timeouts,
+ "test_state": session.test_state,
+ "last_completed_test": session.last_completed_test,
+ "tests": session.tests,
+ "pending_tests": session.pending_tests,
+ "running_tests": session.running_tests,
+ "status": session.status,
+ "browser": session.browser,
+ "date_created": millis_to_iso(session.date_created),
+ "date_started": millis_to_iso(session.date_started),
+ "date_finished": millis_to_iso(session.date_finished),
+ "is_public": session.is_public,
+ "reference_tokens": session.reference_tokens,
+ "expiration_date": millis_to_iso(session.expiration_date),
+ "type": session.type,
+ "malfunctioning_tests": session.malfunctioning_tests
+ }
+
+def serialize_sessions(sessions):
+ serialized_sessions = []
+ for session in sessions:
+ serialized_sessions.append(serialize_session(session))
+ return serialized_sessions
+
+def serialize_device(device):
+ return {
+ "token": device.token,
+ "user_agent": device.user_agent,
+ "name": device.name,
+ "last_active": millis_to_iso(device.last_active)
+ }
+
+def millis_to_iso(millis):
+ if millis is None:
+ return None
+ return datetime.utcfromtimestamp(millis/1000.0).isoformat() + "+00:00"