Skip to content

Commit 3ea679d

Browse files
committed
#44: adding tests for github actions
1 parent 74cab1c commit 3ea679d

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

tests/unit/test_task.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2024 The WfCommons Team.
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
11+
import pytest
12+
13+
from wfcommons.common import Task, TaskType, File, FileLink, Machine, MachineSystem
14+
15+
16+
task_name = "Task Test"
17+
task_id = "task_test_1"
18+
input_files = [File(file_id="file_in_1", size=10, link=FileLink.INPUT), File(file_id="file_in_2", size=20, link=FileLink.INPUT)]
19+
output_files = [File(file_id="file_out_1", size=30, link=FileLink.OUTPUT), File(file_id="file_out_2", size=40, link=FileLink.OUTPUT)]
20+
21+
22+
class TestTask:
23+
24+
@pytest.fixture
25+
def task(self) -> Task:
26+
return Task(
27+
name=task_name,
28+
task_id=task_id,
29+
runtime=123.45,
30+
input_files=input_files,
31+
output_files=output_files,
32+
category="task_test",
33+
machines=[Machine(name="machine_1", cpu = {"coreCount": 48, "speedInMHz": 1200, "vendor": "Vendor Name"})],
34+
program="program",
35+
args=["arg_1", "arg_2"],
36+
avg_cpu=0.5,
37+
bytes_read=12345,
38+
bytes_written=54321,
39+
memory=10,
40+
energy=100,
41+
avg_power=1.0,
42+
priority=100,
43+
executedAt="2024-09-15T08:59:33.699321-04:00",
44+
task_type=TaskType.COMPUTE,
45+
launch_dir="/tmp",
46+
)
47+
48+
@pytest.mark.unit
49+
def test_task_specification(self, task: Task) -> None:
50+
51+
task_specification = {
52+
"name": task_name,
53+
"id": task_id,
54+
"parents": [],
55+
"children": [],
56+
"inputFiles": [str(f) for f in input_files],
57+
"outputFiles": [str(f) for f in output_files]
58+
}
59+
60+
assert(task_specification == task.specification_as_dict())

0 commit comments

Comments
 (0)