Skip to content

Commit

Permalink
Merge pull request #209 from dianakolusheva/test_update
Browse files Browse the repository at this point in the history
Model to tests
  • Loading branch information
dianakolusheva committed Mar 18, 2021
2 parents bc76b79 + af282e3 commit a4df66f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions emmaa/model_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,15 +838,16 @@ def update_model_manager_on_s3(model_name, bucket=EMMAA_BUCKET_NAME):


def model_to_tests(model_name, upload=True, bucket=EMMAA_BUCKET_NAME):
em = EmmaaModel.load_from_s3(model_name, bucket=bucket)
em.run_assembly()
tests = [StatementCheckingTest(stmt) for stmt in em.assembled_stmts if
"""Create StatementCheckingTests from model statements."""
stmts, _ = get_assembled_statements(model_name, bucket=bucket)
config = load_config_from_s3(model_name, bucket=bucket)
tests = [StatementCheckingTest(stmt) for stmt in stmts if
all(stmt.agent_list())]
date_str = make_date_str()
test_description = (
f'These tests were generated from the {em.human_readable_name} '
f'on {date_str[:10]}')
test_name = f'{em.human_readable_name} model test corpus'
f'These tests were generated from the '
f'{config.get("human_readable_name")} on {date_str[:10]}')
test_name = f'{config.get("human_readable_name")} model test corpus'
test_dict = {'test_data': {'description': test_description,
'name': test_name},
'tests': tests}
Expand Down
3 changes: 2 additions & 1 deletion emmaa/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,13 @@ def test_save_load_update_model_manager():
assert find_number_of_files_on_s3(
TEST_BUCKET_NAME, 'results/test/model_manager_', '.pkl') == 2


@mock_s3
def test_model_to_tests():
# Local imports are recommended when using moto
from emmaa.model_tests import model_to_tests, load_tests_from_s3, \
StatementCheckingTest
client = setup_bucket(add_model=True)
client = setup_bucket(add_model=True, add_mm=True)
test_dict = model_to_tests('test', bucket=TEST_BUCKET_NAME)
assert isinstance(test_dict, dict)
assert 'test_data' in test_dict
Expand Down

0 comments on commit a4df66f

Please sign in to comment.