Skip to content
Snippets Groups Projects
Commit 4f5df395 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

tests(agora): migrate tests

parent 9555bce0
No related branches found
No related tags found
No related merge requests found
"""
Basic ParametersIO tests
"""
import pytest
from agora.abc import ParametersABC
class DummyParameters(ParametersABC):
yaml_file = "tests/data/parameters.yaml"
def __init__(self):
super().__init__()
def test_dict(self):
param_dict = dict(a="a", b="b", c=dict(d="d", e="e"))
params = self.from_dict(param_dict)
assert params.to_dict() == param_dict
# Remove
params.to_yaml(self.yaml_file)
def test_yaml(self):
# From yaml
params = self.from_yaml(self.yaml_file)
# To yaml
with open(self.yaml_file, "r") as fd:
yaml_data = fd.read()
assert params.to_yaml() == yaml_data
@classmethod
def default(cls):
return cls.from_dict({})
def test_to_yaml():
DummyParameters.default().to_yaml()
def test_from_yaml():
DummyParameters.default().test_yaml()
def test_to_dict():
DummyParameters.default().to_dict()
"""This is an example test file to show the structure."""
import pytest
from agora.utils.example import ExampleClass, example_function
class TestExampleClass:
x = ExampleClass(1)
def test_add_one(self):
assert self.x.add_one() == 2
def test_add_n(self):
assert self.x.add_n(10) == 11
def test_example_function():
x = example_function(1)
assert isinstance(x, ExampleClass)
assert x.parameter == 1
def test_example_function_fail():
with pytest.raises(ValueError):
example_function("hello")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment