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
4f5df395
Commit
4f5df395
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
tests(agora): migrate tests
parent
9555bce0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/agora/base_test.py
+45
-0
45 additions, 0 deletions
tests/agora/base_test.py
tests/agora/example_test.py
+25
-0
25 additions, 0 deletions
tests/agora/example_test.py
with
70 additions
and
0 deletions
tests/agora/base_test.py
0 → 100644
+
45
−
0
View file @
4f5df395
"""
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 diff is collapsed.
Click to expand it.
tests/agora/example_test.py
0 → 100644
+
25
−
0
View file @
4f5df395
"""
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
"
)
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