From ccf4df877e7fa531a96c7b8e4916ac8cc7835a3c Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Mon, 29 Jul 2024 20:44:49 +0700 Subject: [PATCH] Create test_audit_report.py --- .../pi_network/tests/test_audit_report.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 blockchain_integration/pi_network/tests/test_audit_report.py diff --git a/blockchain_integration/pi_network/tests/test_audit_report.py b/blockchain_integration/pi_network/tests/test_audit_report.py new file mode 100644 index 000000000..9339b151c --- /dev/null +++ b/blockchain_integration/pi_network/tests/test_audit_report.py @@ -0,0 +1,29 @@ +import unittest +from security.audits.audit_report import AuditReport + +class TestAuditReport(unittest.TestCase): + def test_audit_report(self): + audit_id = 'AUDIT_ID' + timestamp = datetime.datetime.now() + event_type = 'TEST_EVENT' + event_data = {'test_data': 'Hello, World!'} + audit_report = AuditReport(audit_id, timestamp, event_type, event_data) + self.assertEqual(audit_report.audit_id, audit_id) + self.assertEqual(audit_report.timestamp, timestamp) + self.assertEqual(audit_report.event_type, event_type) + self.assertEqual(audit_report.event_data, event_data) + + def test_audit_report_to_json(self): + audit_id = 'AUDIT_ID' + timestamp = datetime.datetime.now() + event_type = 'TEST_EVENT' + event_data = {'test_data': 'Hello, World!'} + audit_report = AuditReport(audit_id, timestamp, event_type, event_data) + json_report = audit_report.to_json() + self.assertEqual(json_report['audit_id'], audit_id) + self.assertEqual(json_report['timestamp'], timestamp.isoformat()) + self.assertEqual(json_report['event_type'], event_type) + self.assertEqual(json_report['event_data'], event_data) + +if __name__ == '__main__': + unittest.main()