From 3ea679d0f0123f350dc2057a61f2fdbae25b49dd Mon Sep 17 00:00:00 2001 From: Rafael Ferreira da Silva Date: Sun, 15 Sep 2024 20:01:36 -0400 Subject: [PATCH] #44: adding tests for github actions --- tests/unit/test_task.py | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/unit/test_task.py diff --git a/tests/unit/test_task.py b/tests/unit/test_task.py new file mode 100644 index 0000000..e5fc7f9 --- /dev/null +++ b/tests/unit/test_task.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2024 The WfCommons Team. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +import pytest + +from wfcommons.common import Task, TaskType, File, FileLink, Machine, MachineSystem + + +task_name = "Task Test" +task_id = "task_test_1" +input_files = [File(file_id="file_in_1", size=10, link=FileLink.INPUT), File(file_id="file_in_2", size=20, link=FileLink.INPUT)] +output_files = [File(file_id="file_out_1", size=30, link=FileLink.OUTPUT), File(file_id="file_out_2", size=40, link=FileLink.OUTPUT)] + + +class TestTask: + + @pytest.fixture + def task(self) -> Task: + return Task( + name=task_name, + task_id=task_id, + runtime=123.45, + input_files=input_files, + output_files=output_files, + category="task_test", + machines=[Machine(name="machine_1", cpu = {"coreCount": 48, "speedInMHz": 1200, "vendor": "Vendor Name"})], + program="program", + args=["arg_1", "arg_2"], + avg_cpu=0.5, + bytes_read=12345, + bytes_written=54321, + memory=10, + energy=100, + avg_power=1.0, + priority=100, + executedAt="2024-09-15T08:59:33.699321-04:00", + task_type=TaskType.COMPUTE, + launch_dir="/tmp", + ) + + @pytest.mark.unit + def test_task_specification(self, task: Task) -> None: + + task_specification = { + "name": task_name, + "id": task_id, + "parents": [], + "children": [], + "inputFiles": [str(f) for f in input_files], + "outputFiles": [str(f) for f in output_files] + } + + assert(task_specification == task.specification_as_dict())