def test_check_problem_keyword(session_toy_db): add_keyword(session_toy_db, 'keyword', 'data_domain') add_problem_keyword(session_toy_db, 'iris', 'keyword') problem_keyword = get_problem_keyword_by_name( session_toy_db, 'iris', 'keyword' ) assert isinstance(problem_keyword, ProblemKeyword) assert problem_keyword.problem.name == 'iris' assert problem_keyword.keyword.name == 'keyword' assert problem_keyword.description is None err_msg = 'Attempting to update an existing problem-keyword relationship' with pytest.raises(ValueError, match=err_msg): add_problem_keyword(session_toy_db, 'iris', 'keyword') add_problem_keyword(session_toy_db, 'iris', 'keyword', description='new description', force=True) problem_keyword = get_problem_keyword_by_name( session_toy_db, 'iris', 'keyword' ) assert problem_keyword.description == 'new description'
def test_check_keyword(session_scope_function): add_keyword(session_scope_function, 'keyword', 'data_domain') keyword = get_keyword_by_name(session_scope_function, None) assert isinstance(keyword, list) assert len(keyword) == 1 keyword = get_keyword_by_name(session_scope_function, 'keyword') assert isinstance(keyword, Keyword) assert keyword.name == 'keyword' assert keyword.type == 'data_domain' assert keyword.category is None assert keyword.description is None err_msg = 'Attempting to update an existing keyword' with pytest.raises(ValueError, match=err_msg): add_keyword(session_scope_function, 'keyword', 'data_domain') add_keyword(session_scope_function, 'keyword', 'data_science_theme', category='some cat', description='new description', force=True) keyword = get_keyword_by_name(session_scope_function, 'keyword') assert keyword.type == 'data_science_theme' assert keyword.category == 'some cat' assert keyword.description == 'new description'