def test_output(out): """should output ref result list JSON""" query_str = 'genesis 50:20' yvs.main(query_str) output = out.getvalue().rstrip() results = yvs.get_result_list(query_str) feedback = yvs.core.get_result_list_feedback_str(results).rstrip() nose.assert_equal(output, feedback)
def test_output(out): """should output ref result list XML""" query_str = 'genesis 50:20' yvs.main(query_str) output = out.getvalue().strip() results = yvs.get_result_list(query_str) xml = yvs.shared.get_result_list_xml(results).strip() nose.assert_equal(output, xml)
def test_null_result(out): """should output "No Results" JSON item for empty ref result list""" query_str = 'xyz' yvs.main(query_str) feedback_str = out.getvalue() feedback = json.loads(feedback_str) nose.assert_equal(len(feedback['items']), 1, 'result item is missing') item = feedback['items'][0] nose.assert_equal(item['title'], 'No Results') nose.assert_equal(item['valid'], False)
def test_null_result(out): """should output "No Results" XML item for empty ref result list""" query_str = 'xyz' yvs.main(query_str) xml = out.getvalue().strip() root = ET.fromstring(xml) item = root.find('item') nose.assert_is_not_none(item, '<item> element is missing') nose.assert_equal(item.get('valid'), 'no') title = item.find('title') nose.assert_equal(title.text, 'No Results')