Skip to content

Commit

Permalink
more test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Nov 10, 2023
1 parent cc42f0f commit fbd205d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions neurodocker/reproenv/tests/test_renderers_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_docker_renderer_add_template():

d = {
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar"},
"env": {"foo": "bar"},
Expand Down Expand Up @@ -64,6 +65,7 @@ def test_docker_renderer_add_template():
# Test required arguments.
d = {
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar"},
"env": {"foo": "bar"},
Expand All @@ -90,6 +92,7 @@ def test_docker_renderer_add_template():

d = {
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar"},
"env": {"foo": "bar"},
Expand Down
2 changes: 2 additions & 0 deletions neurodocker/reproenv/tests/test_renderers_singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_singularity_renderer_add_template():

d = {
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar"},
"env": {"foo": "bar"},
Expand Down Expand Up @@ -59,6 +60,7 @@ def test_singularity_renderer_add_template():

d = {
"name": "baz",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar"},
"env": {"foo": "bar"},
Expand Down
29 changes: 25 additions & 4 deletions neurodocker/reproenv/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ def test_validate_template_invalid_templates():
with pytest.raises(exceptions.TemplateError, match="'name' is a required property"):
_validate_template({})

with pytest.raises(exceptions.TemplateError, match="{'name': 'bar'} is not valid"):
_validate_template({"name": "bar"})
with pytest.raises(
exceptions.TemplateError, match="is not valid under any of the given schemas"
):
_validate_template({"name": "bar", "url": "some-url"})

# missing 'name' top-level key
with pytest.raises(exceptions.TemplateError, match="'name' is a required property"):
Expand All @@ -28,6 +30,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": 1234,
"url": "some-url",
"binaries": {"urls": {"1.0.0": "foobar.com"}, "instructions": "foobar"},
}
)
Expand All @@ -43,6 +46,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar.com"},
# "instructions": "foobar",
Expand All @@ -58,6 +62,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar.com"},
"env": {"foo": ["foo"]},
Expand All @@ -71,6 +76,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
# "urls": {"1.0.0": "foobar.com"},
"instructions": "foobar"
Expand All @@ -89,6 +95,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar.com"},
"instructions": "foobar",
Expand All @@ -108,6 +115,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar.com"},
"instructions": "foobar",
Expand All @@ -134,6 +142,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"source": {"urls": {"1.0.0": "foobar.com"}, "instructions": "foobar"},
}
)
Expand All @@ -145,6 +154,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"source": {
# "instructions": "foobar",
},
Expand All @@ -159,6 +169,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"source": {"env": {"foo": ["foo"]}, "instructions": "foobar"},
}
)
Expand All @@ -172,7 +183,11 @@ def test_validate_template_invalid_templates():
),
):
_validate_template(
{"name": "foobar", "source": {"instructions": "foobar", "extra": ""}}
{
"name": "foobar",
"url": "some-url",
"source": {"instructions": "foobar", "extra": ""},
}
)

# extra keys in dependencies
Expand All @@ -186,6 +201,7 @@ def test_validate_template_invalid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"source": {
"instructions": "foobar",
"dependencies": {"apt": [], "fakemngr": []},
Expand All @@ -202,15 +218,19 @@ def test_validate_template_valid_templates():
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {"urls": {"v1": "foo"}, "instructions": "foobar"},
}
)
_validate_template({"name": "foobar", "source": {"instructions": "foobar"}})
_validate_template(
{"name": "foobar", "url": "some-url", "source": {"instructions": "foobar"}}
)

# bigger templates
_validate_template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"v1": "foo"},
"env": {"baz": "cat", "boo": "123"},
Expand All @@ -233,6 +253,7 @@ def test_register(tmp_path: Path):

_one_test_template: types.TemplateType = {
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"1.0.0": "foobar.com"},
"env": {"foo": "bar"},
Expand Down
4 changes: 4 additions & 0 deletions neurodocker/reproenv/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
def test_template():
d = {
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"v1": "foo"},
"env": {"baz": "cat", "boo": "123"},
Expand Down Expand Up @@ -62,6 +63,7 @@ def test_template():
t = template.Template(
{
"name": "foobar",
"url": "some-url",
"binaries": {
"urls": {"v1": "foo"},
"env": {"baz": "cat", "boo": "123"},
Expand All @@ -78,6 +80,7 @@ def test_template():
t = template.Template(
{
"name": "foobar",
"url": "some-url",
"source": {
"env": {"foo": "bar"},
"instructions": "echo foo\n{{ self.boo }}",
Expand Down Expand Up @@ -197,6 +200,7 @@ def test_template_alert():
d: types.TemplateType = {
"alert": "This is an alert!",
"name": "testing",
"url": "some-url",
"binaries": {"urls": {"foo": "foo.baz.tar.gz"}, "instructions": "do nothing"},
}
tmpl = template.Template(d)
Expand Down

0 comments on commit fbd205d

Please sign in to comment.