From dbb0ed7ef797ef8135cf955e2e8ea94270892fbe Mon Sep 17 00:00:00 2001 From: Saurabh Mogre Date: Thu, 6 Jul 2023 09:49:32 -0700 Subject: [PATCH] move test for ingredient count options --- cellpack/tests/test_env.py | 74 ------------------------------ cellpack/tests/test_ingredient.py | 75 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 74 deletions(-) create mode 100644 cellpack/tests/test_ingredient.py diff --git a/cellpack/tests/test_env.py b/cellpack/tests/test_env.py index c559f0ef2..386f6c3ac 100644 --- a/cellpack/tests/test_env.py +++ b/cellpack/tests/test_env.py @@ -11,7 +11,6 @@ """ from unittest.mock import MagicMock -import pytest from cellpack.autopack.Environment import Environment test_config = { @@ -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 diff --git a/cellpack/tests/test_ingredient.py b/cellpack/tests/test_ingredient.py new file mode 100644 index 000000000..8dd493234 --- /dev/null +++ b/cellpack/tests/test_ingredient.py @@ -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