#!/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)

[((642, 673), 'apyhgnc.apyhgnc.fetch', 'apyhgnc.fetch', (['"""symbol"""', '"""ZNF3"""'], {}), "('symbol', 'ZNF3')\n", (655, 673), False, 'from apyhgnc import apyhgnc\n'), ((678, 726), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_fetch_symbol_znf3'], {}), '(result, df_fetch_symbol_znf3)\n', (696, 726), False, 'from pandas.testing import assert_frame_equal\n'), ((796, 820), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), '()\n', (818, 820), False, 'import asyncio\n'), ((910, 958), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_fetch_symbol_znf3'], {}), '(result, df_fetch_symbol_znf3)\n', (928, 958), False, 'from pandas.testing import assert_frame_equal\n'), ((1038, 1060), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', (['"""BRAF"""'], {}), "('BRAF')\n", (1052, 1060), False, 'from apyhgnc import apyhgnc\n'), ((1065, 1111), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_all_braf'], {}), '(result, df_search_all_braf)\n', (1083, 1111), False, 'from pandas.testing import assert_frame_equal\n'), ((1177, 1201), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), '()\n', (1199, 1201), False, 'import asyncio\n'), ((1282, 1328), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_all_braf'], {}), '(result, df_search_all_braf)\n', (1300, 1328), False, 'from pandas.testing import assert_frame_equal\n'), ((1396, 1428), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', (['"""symbol"""', '"""BRAF"""'], {}), "('symbol', 'BRAF')\n", (1410, 1428), False, 'from apyhgnc import apyhgnc\n'), ((1433, 1482), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_braf'], {}), '(result, df_search_symbol_braf)\n', (1451, 1482), False, 'from pandas.testing import assert_frame_equal\n'), ((1554, 1578), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), '()\n', (1576, 1578), False, 'import asyncio\n'), ((1669, 1718), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_braf'], {}), '(result, df_search_symbol_braf)\n', (1687, 1718), False, 'from pandas.testing import assert_frame_equal\n'), ((1798, 1837), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', ([], {'symbol': "['BRAF', 'ZNF3']"}), "(symbol=['BRAF', 'ZNF3'])\n", (1812, 1837), False, 'from apyhgnc import apyhgnc\n'), ((1842, 1897), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbols_braf_znf3'], {}), '(result, df_search_symbols_braf_znf3)\n', (1860, 1897), False, 'from pandas.testing import assert_frame_equal\n'), ((1981, 2005), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), '()\n', (2003, 2005), False, 'import asyncio\n'), ((2103, 2158), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbols_braf_znf3'], {}), '(result, df_search_symbols_braf_znf3)\n', (2121, 2158), False, 'from pandas.testing import assert_frame_equal\n'), ((2238, 2286), 'apyhgnc.apyhgnc.search', 'apyhgnc.search', ([], {'symbol': '"""BRAF"""', 'status': '"""Approved"""'}), "(symbol='BRAF', status='Approved')\n", (2252, 2286), False, 'from apyhgnc import apyhgnc\n'), ((2291, 2346), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_and_status'], {}), '(result, df_search_symbol_and_status)\n', (2309, 2346), False, 'from pandas.testing import assert_frame_equal\n'), ((2430, 2454), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), '()\n', (2452, 2454), False, 'import asyncio\n'), ((2561, 2616), 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_and_status'], {}), '(result, df_search_symbol_and_status)\n', (2579, 2616), False, 'from pandas.testing import assert_frame_equal\n'), ((259, 273), 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ([], {}), '()\n', (271, 273), False, 'from apyhgnc import apyhgnc\n'), ((388, 402), 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ([], {}), '()\n', (400, 402), False, 'from apyhgnc import apyhgnc\n'), ((487, 501), 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ([], {}), '()\n', (499, 501), False, 'from apyhgnc import apyhgnc\n'), ((867, 899), 'apyhgnc.apyhgnc.afetch', 'apyhgnc.afetch', (['"""symbol"""', '"""ZNF3"""'], {}), "('symbol', 'ZNF3')\n", (881, 899), False, 'from apyhgnc import apyhgnc\n'), ((1248, 1271), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', (['"""BRAF"""'], {}), "('BRAF')\n", (1263, 1271), False, 'from apyhgnc import apyhgnc\n'), ((1625, 1658), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', (['"""symbol"""', '"""BRAF"""'], {}), "('symbol', 'BRAF')\n", (1640, 1658), False, 'from apyhgnc import apyhgnc\n'), ((2052, 2092), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', ([], {'symbol': "['BRAF', 'ZNF3']"}), "(symbol=['BRAF', 'ZNF3'])\n", (2067, 2092), False, 'from apyhgnc import apyhgnc\n'), ((2501, 2550), 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', ([], {'symbol': '"""BRAF"""', 'status': '"""Approved"""'}), "(symbol='BRAF', status='Approved')\n", (2516, 2550), False, 'from apyhgnc import apyhgnc\n')]