Skip to content

Commit

Permalink
Merge pull request #1128 from pyiron/test_server
Browse files Browse the repository at this point in the history
Add tests for server object
  • Loading branch information
jan-janssen authored Jun 9, 2023
2 parents b717a0b + 1db53ef commit b454784
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyiron_base/jobs/job/extension/server/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(
):
self._cores = cores
self._threads = threads
self._active_queue = None
self._gpus = gpus
self._run_time = None
self._memory_limit = None
Expand Down
29 changes: 29 additions & 0 deletions tests/server/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,34 @@ def test_set_memory_limit(self):
)


class TestServerHDF(unittest.TestCase):
def test_to_and_from_hdf(self):
server_empty = Server()
server_full = Server()
server_full.gpus = 10
server_full.cores = 10
server_full.threads = 2
server_full.new_hdf = False
hdf_dict_empty = {"server": {}}
hdf_dict_full = {"server": {}}
self.assertTrue(server_empty.new_hdf)
self.assertFalse(server_full.new_hdf)
self.assertIsNone(server_empty.gpus)
self.assertEqual(server_full.gpus, 10)
self.assertEqual(server_full.cores, 10)
self.assertEqual(server_full.threads, 2)
self.assertFalse(server_full.new_hdf)
server_empty.to_hdf(hdf=hdf_dict_empty)
server_full.to_hdf(hdf=hdf_dict_full)
server_from_hdf = Server()
server_from_hdf.from_hdf(hdf=hdf_dict_full)
self.assertEqual(hdf_dict_full["server"]["gpus"], 10)
self.assertTrue("gpus" not in hdf_dict_empty["server"].keys())
self.assertEqual(server_from_hdf.gpus, 10)
self.assertEqual(server_from_hdf.cores, 10)
self.assertEqual(server_from_hdf.threads, 2)
self.assertFalse(server_from_hdf.new_hdf)


if __name__ == "__main__":
unittest.main()

0 comments on commit b454784

Please sign in to comment.