Added tests for Moved node builder star files to types folder.py

This commit is contained in:
Alberto Soutullo 2023-03-04 20:58:53 +01:00 committed by Alberto Soutullo Rendo
parent ca4bb88931
commit 557e149a2e
4 changed files with 59 additions and 0 deletions

View File

View File

@ -0,0 +1,33 @@
import json
import unittest
import os
from .. import files
class TestFiles(unittest.TestCase):
def test_load_config_file(self):
config = files.load_config_file("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")
def test_load_topology(self):
test_topology = files.load_topology("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")
def test_save_messages_to_json(self):
msgs_dict = {"test": "test"}
files.save_messages_to_json(msgs_dict)
with open("messages.json", "r") as f:
self.assertEqual(json.load(f), msgs_dict)
os.remove("messages.json")

View File

@ -0,0 +1,8 @@
{
"general":{
"prng_seed" : 1234
},
"kurtosis": {
"enclave_name": "test"
}
}

View File

@ -0,0 +1,18 @@
{
"containers": {
"containers_0": [
"node_0"
]
},
"nodes": {
"node_0": {
"static_nodes": [],
"subnetwork": "subnetwork_0",
"image": "nim-waku",
"node_config": "node_0.toml",
"node_log": "node_0.log",
"port_shift": 0,
"container_id": "containers_0"
}
}
}