From ca738873617152df30fe2d5fe62a8913e22f553a Mon Sep 17 00:00:00 2001 From: Alberto Soutullo Date: Thu, 9 Mar 2023 16:46:11 +0100 Subject: [PATCH] Fixed imports in wls tests --- wls-module/src/tests/test_wls.py | 12 ++++++++---- wls-module/src/utils/tests/test_files.py | 10 ++++++---- wls-module/src/utils/tests/test_payloads.py | 10 +++++++--- wls-module/src/utils/wls_logger.py | 1 + 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/wls-module/src/tests/test_wls.py b/wls-module/src/tests/test_wls.py index 093b142..a6e0b19 100644 --- a/wls-module/src/tests/test_wls.py +++ b/wls-module/src/tests/test_wls.py @@ -1,14 +1,18 @@ +# Python Imports import unittest import random from unittest.mock import mock_open, patch +# Project Imports from src import wls -random.seed(0) - class TestWLS(unittest.TestCase): + @classmethod + def setUpClass(cls): + random.seed(1) + def create_patch(self, name): patcher = patch(name) thing = patcher.start() @@ -178,8 +182,8 @@ class TestWLS(unittest.TestCase): emitter_address, topic = wls._select_emitter_with_topic(emitters) - self.assertEqual(emitter_address, "http://5:6/") - self.assertEqual(topic, "test2b") + self.assertEqual(emitter_address, "http://1:2/") + self.assertEqual(topic, "test1a") def test__inject_message(self): mock_dist = self.create_patch('src.utils.payloads.make_payload_dist') diff --git a/wls-module/src/utils/tests/test_files.py b/wls-module/src/utils/tests/test_files.py index 5073231..17ef394 100644 --- a/wls-module/src/utils/tests/test_files.py +++ b/wls-module/src/utils/tests/test_files.py @@ -1,29 +1,31 @@ +# Python Imports import json import unittest import os +# Project Imports from src.utils import files class TestFiles(unittest.TestCase): def test_load_config_file(self): - config = files.load_config_file("test_files/test_config.json") + config = files.load_config_file("src/utils/tests/test_files/test_config.json") self.assertEqual(config["general"]["prng_seed"], 1234) self.assertEqual(config["kurtosis"]["enclave_name"], "test") def test_config_file_error(self): with self.assertRaises(FileNotFoundError): - files.load_config_file("test_files/test_config_error.json") + files.load_config_file("src/utils/tests/test_files/test_config_error.json") def test_load_topology(self): - test_topology = files.load_topology("test_files/test_topology.json") + test_topology = files.load_topology("src/utils/tests/test_files/test_topology.json") self.assertEqual(test_topology["containers"]["containers_0"][0], "node_0") self.assertEqual(test_topology["nodes"]["node_0"]["image"], "nim-waku") def test_load_topology_error(self): with self.assertRaises(FileNotFoundError): - files.load_topology("test_files/test_topology_error.json") + files.load_topology("src/utils/tests/test_files/test_topology_error.json") def test_save_messages_to_json(self): msgs_dict = {"test": "test"} diff --git a/wls-module/src/utils/tests/test_payloads.py b/wls-module/src/utils/tests/test_payloads.py index c9a0d2e..5565527 100644 --- a/wls-module/src/utils/tests/test_payloads.py +++ b/wls-module/src/utils/tests/test_payloads.py @@ -1,14 +1,18 @@ +# Python Imports import unittest -import random from unittest.mock import patch +import random +# Project Imports from src.utils import payloads -random.seed(1) - class TestPayloads(unittest.TestCase): + @classmethod + def setUpClass(cls): + random.seed(1) + def create_patch(self, name): patcher = patch(name) thing = patcher.start() diff --git a/wls-module/src/utils/wls_logger.py b/wls-module/src/utils/wls_logger.py index 1d19b9d..20a4e2f 100644 --- a/wls-module/src/utils/wls_logger.py +++ b/wls-module/src/utils/wls_logger.py @@ -1,3 +1,4 @@ +# Python Imports import sys import logging