Skip to content

Commit

Permalink
move test for ingredient count options
Browse files Browse the repository at this point in the history
  • Loading branch information
mogres committed Jul 6, 2023
1 parent b526258 commit dbb0ed7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 74 deletions.
74 changes: 0 additions & 74 deletions cellpack/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"""

from unittest.mock import MagicMock
import pytest
from cellpack.autopack.Environment import Environment

test_config = {
Expand Down Expand Up @@ -60,76 +59,3 @@ def test_is_two_d():
env.grid = mock

assert not env.is_two_d()


@pytest.mark.parametrize(
"ingredient_info, output",
[
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {"distribution": "uniform", "min": 1, "max": 1},
},
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {"distribution": "uniform", "min": 1, "max": 1},
},
),
(
{
"name": "test",
"type": "single_sphere",
},
"Ingredient info must contain a count",
),
(
{
"name": "test",
"type": "single_sphere",
"count": -1,
},
"Ingredient count must be greater than or equal to 0",
),
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {},
},
"Ingredient count options must contain a distribution",
),
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {
"distribution": "invalid_distribution",
},
},
"invalid_distribution is not a valid count distribution",
),
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {
"distribution": "uniform",
},
},
"Missing option 'min' for uniform distribution",
),
],
)
def test_validate_ingredient_info(ingredient_info, output):
try:
validated_info = Environment.validate_ingredient_info(ingredient_info)
assert validated_info == output
except Exception as e:
assert str(e) == output
75 changes: 75 additions & 0 deletions cellpack/tests/test_ingredient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import pytest
from ..autopack.ingredient import Ingredient


@pytest.mark.parametrize(
"ingredient_info, output",
[
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {"distribution": "uniform", "min": 1, "max": 1},
},
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {"distribution": "uniform", "min": 1, "max": 1},
},
),
(
{
"name": "test",
"type": "single_sphere",
},
"Ingredient info must contain a count",
),
(
{
"name": "test",
"type": "single_sphere",
"count": -1,
},
"Ingredient count must be greater than or equal to 0",
),
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {},
},
"Ingredient count options must contain a distribution",
),
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {
"distribution": "invalid_distribution",
},
},
"invalid_distribution is not a valid count distribution",
),
(
{
"name": "test",
"type": "single_sphere",
"count": 1,
"count_options": {
"distribution": "uniform",
},
},
"Missing option 'min' for uniform distribution",
),
],
)
def test_validate_ingredient_info(ingredient_info, output):
try:
validated_info = Ingredient.validate_ingredient_info(ingredient_info)
assert validated_info == output
except Exception as e:
assert str(e) == output

0 comments on commit dbb0ed7

Please sign in to comment.