#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Created by Roberto Preste
import pytest
import asyncio
from pandas.testing import assert_frame_equal
from apyhgnc import apyhgnc


# apyhgnc.info

def test_info_searchableFields(searchable_fields):
    result = apyhgnc.info().searchableFields
    assert result == searchable_fields


def test_info_storedFields(stored_fields):
    result = apyhgnc.info().storedFields
    assert result == stored_fields


def test_info_url():
    result = apyhgnc.info().url
    assert result == "http://rest.genenames.org/info"


# apyhgnc.fetch

def test_fetch_symbol_znf3(df_fetch_symbol_znf3):
    result = apyhgnc.fetch("symbol", "ZNF3")
    assert_frame_equal(result, df_fetch_symbol_znf3)


def test_fetch_symbol_znf3_async(df_fetch_symbol_znf3):
    loop = asyncio.get_event_loop()
    result = loop.run_until_complete(
        apyhgnc.afetch("symbol", "ZNF3")
    )
    assert_frame_equal(result, df_fetch_symbol_znf3)


# apyhgnc.search

def test_search_all_braf(df_search_all_braf):
    result = apyhgnc.search("BRAF")
    assert_frame_equal(result, df_search_all_braf)


def test_search_all_braf_async(df_search_all_braf):
    loop = asyncio.get_event_loop()
    result = loop.run_until_complete(
        apyhgnc.asearch("BRAF")
    )
    assert_frame_equal(result, df_search_all_braf)


def test_search_symbol_braf(df_search_symbol_braf):
    result = apyhgnc.search("symbol", "BRAF")
    assert_frame_equal(result, df_search_symbol_braf)


def test_search_symbol_braf_async(df_search_symbol_braf):
    loop = asyncio.get_event_loop()
    result = loop.run_until_complete(
        apyhgnc.asearch("symbol", "BRAF")
    )
    assert_frame_equal(result, df_search_symbol_braf)


def test_search_symbols_braf_znf3(df_search_symbols_braf_znf3):
    result = apyhgnc.search(symbol=["BRAF", "ZNF3"])
    assert_frame_equal(result, df_search_symbols_braf_znf3)


def test_search_symbols_braf_znf3_async(df_search_symbols_braf_znf3):
    loop = asyncio.get_event_loop()
    result = loop.run_until_complete(
        apyhgnc.asearch(symbol=["BRAF", "ZNF3"])
    )
    assert_frame_equal(result, df_search_symbols_braf_znf3)


def test_search_symbol_and_status(df_search_symbol_and_status):
    result = apyhgnc.search(symbol="BRAF", status="Approved")
    assert_frame_equal(result, df_search_symbol_and_status)


def test_search_symbol_and_status_async(df_search_symbol_and_status):
    loop = asyncio.get_event_loop()
    result = loop.run_until_complete(
        apyhgnc.asearch(symbol="BRAF", status="Approved")
    )
    assert_frame_equal(result, df_search_symbol_and_status)

[((30, 13, 30, 44), 'apyhgnc.apyhgnc.fetch', 'apyhgnc.fetch', ({(30, 27, 30, 35): '"""symbol"""', (30, 37, 30, 43): '"""ZNF3"""'}, {}), "('symbol', 'ZNF3')", False, 'from apyhgnc import apyhgnc\n'), ((31, 4, 31, 52), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(31, 23, 31, 29): 'result', (31, 31, 31, 51): 'df_fetch_symbol_znf3'}, {}), '(result, df_fetch_symbol_znf3)', False, 'from pandas.testing import assert_frame_equal\n'), ((35, 11, 35, 35), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ({}, {}), '()', False, 'import asyncio\n'), ((39, 4, 39, 52), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(39, 23, 39, 29): 'result', (39, 31, 39, 51): 'df_fetch_symbol_znf3'}, {}), '(result, df_fetch_symbol_znf3)', False, 'from pandas.testing import assert_frame_equal\n'), ((45, 13, 45, 35), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', ({(45, 28, 45, 34): '"""BRAF"""'}, {}), "('BRAF')", False, 'from apyhgnc import apyhgnc\n'), ((46, 4, 46, 50), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(46, 23, 46, 29): 'result', (46, 31, 46, 49): 'df_search_all_braf'}, {}), '(result, df_search_all_braf)', False, 'from pandas.testing import assert_frame_equal\n'), ((50, 11, 50, 35), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ({}, {}), '()', False, 'import asyncio\n'), ((54, 4, 54, 50), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(54, 23, 54, 29): 'result', (54, 31, 54, 49): 'df_search_all_braf'}, {}), '(result, df_search_all_braf)', False, 'from pandas.testing import assert_frame_equal\n'), ((58, 13, 58, 45), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', ({(58, 28, 58, 36): '"""symbol"""', (58, 38, 58, 44): '"""BRAF"""'}, {}), "('symbol', 'BRAF')", False, 'from apyhgnc import apyhgnc\n'), ((59, 4, 59, 53), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(59, 23, 59, 29): 'result', (59, 31, 59, 52): 'df_search_symbol_braf'}, {}), '(result, df_search_symbol_braf)', False, 'from pandas.testing import assert_frame_equal\n'), ((63, 11, 63, 35), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ({}, {}), '()', False, 'import asyncio\n'), ((67, 4, 67, 53), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(67, 23, 67, 29): 'result', (67, 31, 67, 52): 'df_search_symbol_braf'}, {}), '(result, df_search_symbol_braf)', False, 'from pandas.testing import assert_frame_equal\n'), ((71, 13, 71, 52), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', (), '', False, 'from apyhgnc import apyhgnc\n'), ((72, 4, 72, 59), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(72, 23, 72, 29): 'result', (72, 31, 72, 58): 'df_search_symbols_braf_znf3'}, {}), '(result, df_search_symbols_braf_znf3)', False, 'from pandas.testing import assert_frame_equal\n'), ((76, 11, 76, 35), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ({}, {}), '()', False, 'import asyncio\n'), ((80, 4, 80, 59), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(80, 23, 80, 29): 'result', (80, 31, 80, 58): 'df_search_symbols_braf_znf3'}, {}), '(result, df_search_symbols_braf_znf3)', False, 'from pandas.testing import assert_frame_equal\n'), ((84, 13, 84, 61), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', (), '', False, 'from apyhgnc import apyhgnc\n'), ((85, 4, 85, 59), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(85, 23, 85, 29): 'result', (85, 31, 85, 58): 'df_search_symbol_and_status'}, {}), '(result, df_search_symbol_and_status)', False, 'from pandas.testing import assert_frame_equal\n'), ((89, 11, 89, 35), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ({}, {}), '()', False, 'import asyncio\n'), ((93, 4, 93, 59), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', ({(93, 23, 93, 29): 'result', (93, 31, 93, 58): 'df_search_symbol_and_status'}, {}), '(result, df_search_symbol_and_status)', False, 'from pandas.testing import assert_frame_equal\n'), ((13, 13, 13, 27), 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ({}, {}), '()', False, 'from apyhgnc import apyhgnc\n'), ((18, 13, 18, 27), 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ({}, {}), '()', False, 'from apyhgnc import apyhgnc\n'), ((23, 13, 23, 27), 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ({}, {}), '()', False, 'from apyhgnc import apyhgnc\n'), ((37, 8, 37, 40), 'apyhgnc.apyhgnc.afetch', 'apyhgnc.afetch', ({(37, 23, 37, 31): '"""symbol"""', (37, 33, 37, 39): '"""ZNF3"""'}, {}), "('symbol', 'ZNF3')", False, 'from apyhgnc import apyhgnc\n'), ((52, 8, 52, 31), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', ({(52, 24, 52, 30): '"""BRAF"""'}, {}), "('BRAF')", False, 'from apyhgnc import apyhgnc\n'), ((65, 8, 65, 41), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', ({(65, 24, 65, 32): '"""symbol"""', (65, 34, 65, 40): '"""BRAF"""'}, {}), "('symbol', 'BRAF')", False, 'from apyhgnc import apyhgnc\n'), ((78, 8, 78, 48), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', (), '', False, 'from apyhgnc import apyhgnc\n'), ((91, 8, 91, 57), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', (), '', False, 'from apyhgnc import apyhgnc\n')]