Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Swain Lab
aliby
alibylite
Commits
0d945ec3
Commit
0d945ec3
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
tests(agora): fix tests
parent
be7f6480
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/agora/base_test.py
+27
-24
27 additions, 24 deletions
tests/agora/base_test.py
tests/agora/conftest.py
+27
-0
27 additions, 0 deletions
tests/agora/conftest.py
with
54 additions
and
24 deletions
tests/agora/base_test.py
+
27
−
24
View file @
0d945ec3
...
@@ -8,38 +8,41 @@ from agora.abc import ParametersABC
...
@@ -8,38 +8,41 @@ from agora.abc import ParametersABC
class
DummyParameters
(
ParametersABC
):
class
DummyParameters
(
ParametersABC
):
# TODO add default data folder and load for all tests
def
__init__
(
self
,
**
kwargs
):
yaml_file
=
"
tests/agora/data/parameters.yaml
"
super
().
__init__
(
**
kwargs
)
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
@classmethod
def
default
(
cls
):
def
default
(
cls
):
# Necessary empty builder
return
cls
.
from_dict
({})
return
cls
.
from_dict
({})
def
test_to_yaml
():
def
test_from_yaml
(
yaml_file
):
DummyParameters
.
default
().
to_yaml
()
# From yaml
params
=
DummyParameters
.
from_yaml
(
yaml_file
)
def
test_from_yaml
():
def
test_from_stdin
(
yaml_file
):
DummyParameters
.
default
().
test_yaml
()
# From yaml
params
=
DummyParameters
.
from_yaml
(
yaml_file
)
# To yaml
assert
isinstance
(
params
,
ParametersABC
)
def
test_to_yaml
(
yaml_file
):
with
open
(
yaml_file
,
"
r
"
)
as
fd
:
yaml_data
=
fd
.
read
()
params
=
DummyParameters
.
from_yaml
(
yaml_file
)
assert
params
.
to_yaml
()
==
yaml_data
def
test_dict
(
example_dict
):
params
=
DummyParameters
(
**
example_dict
)
assert
params
.
to_dict
()
==
param_dict
# Remove
params
.
to_yaml
(
"
outfile.yml
"
)
def
test_to_dict
():
def
test_to_dict
():
...
...
This diff is collapsed.
Click to expand it.
tests/agora/conftest.py
0 → 100644
+
27
−
0
View file @
0d945ec3
#!/usr/bin/env jupyter
"""
Load data necessary to test agora.
"""
import
typing
as
t
from
pathlib
import
Path
import
pytest
@pytest.fixture
(
scope
=
"
module
"
)
def
yaml_file
():
return
Path
(
__file__
).
parent
/
"
data/parameters.yaml
"
@pytest.fixture
(
scope
=
"
module
"
,
autouse
=
True
)
def
parameters_example
()
->
t
.
Dict
:
return
dict
(
string
=
"
abc
"
,
number
=
1
,
boolean
=
True
,
dictionary
=
dict
(
empty_dict
=
dict
(),
string
=
"
def
"
,
number
=
2
,
),
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment