Skip to content

Commit 4927ff3

Browse files
committed
adding utils unit test
1 parent 14a8d70 commit 4927ff3

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/unit/test_utils.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2025 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 json
12+
import pathlib
13+
import pytest
14+
import wfcommons.utils
15+
16+
from typing import Dict
17+
18+
19+
class TestUtils:
20+
21+
@pytest.mark.unit
22+
def test_best_fit_distribution(self) -> None:
23+
pass
24+
25+
@pytest.mark.parametrize(
26+
"distribution,min_value,max_value,variable",
27+
[
28+
pytest.param(None, 10, 100, 10),
29+
pytest.param({"name": "norm", "params": [0.08688656476267097, 0.2572832376513094]}, 10, 100, 10),
30+
],
31+
)
32+
def test_generate_rvs(self, distribution: Dict, min_value: float, max_value: float, variable: float) -> None:
33+
assert(min_value <= wfcommons.utils.generate_rvs(distribution, min_value, max_value) <= max_value )
34+
35+
@pytest.mark.parametrize(
36+
"n,r,combinations",
37+
[
38+
pytest.param(2, 2, 1),
39+
pytest.param(10, 2, 45),
40+
pytest.param(10, 3, 120),
41+
],
42+
)
43+
def test_ncr(self, n: int, r: int, combinations: int) -> None:
44+
assert(wfcommons.utils.ncr(n, r) == combinations)

0 commit comments

Comments
 (0)