#!/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, 'apyhgnc.apyhgnc.fetch', 'apyhgnc.fetch', (['"""symbol"""', '"""ZNF3"""'], {}), False, 'from apyhgnc import apyhgnc\n'), (31, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_fetch_symbol_znf3'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (35, 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), False, 'import asyncio\n'), (39, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_fetch_symbol_znf3'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (45, 'apyhgnc.apyhgnc.search', 'apyhgnc.search', (['"""BRAF"""'], {}), False, 'from apyhgnc import apyhgnc\n'), (46, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_all_braf'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (50, 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), False, 'import asyncio\n'), (54, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_all_braf'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (58, 'apyhgnc.apyhgnc.search', 'apyhgnc.search', (['"""symbol"""', '"""BRAF"""'], {}), False, 'from apyhgnc import apyhgnc\n'), (59, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_braf'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (63, 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), False, 'import asyncio\n'), (67, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_braf'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (71, 'apyhgnc.apyhgnc.search', 'apyhgnc.search', ([], {'symbol': "['BRAF', 'ZNF3']"}), False, 'from apyhgnc import apyhgnc\n'), (72, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbols_braf_znf3'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (76, 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), False, 'import asyncio\n'), (80, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbols_braf_znf3'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (84, 'apyhgnc.apyhgnc.search', 'apyhgnc.search', ([], {'symbol': '"""BRAF"""', 'status': '"""Approved"""'}), False, 'from apyhgnc import apyhgnc\n'), (85, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_and_status'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (89, 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), False, 'import asyncio\n'), (93, 'pandas.testing.assert_frame_equal', 'assert_frame_equal', (['result', 'df_search_symbol_and_status'], {}), False, 'from pandas.testing import assert_frame_equal\n'), (13, 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ([], {}), False, 'from apyhgnc import apyhgnc\n'), (18, 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ([], {}), False, 'from apyhgnc import apyhgnc\n'), (23, 'apyhgnc.apyhgnc.info', 'apyhgnc.info', ([], {}), False, 'from apyhgnc import apyhgnc\n'), (37, 'apyhgnc.apyhgnc.afetch', 'apyhgnc.afetch', (['"""symbol"""', '"""ZNF3"""'], {}), False, 'from apyhgnc import apyhgnc\n'), (52, 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', (['"""BRAF"""'], {}), False, 'from apyhgnc import apyhgnc\n'), (65, 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', (['"""symbol"""', '"""BRAF"""'], {}), False, 'from apyhgnc import apyhgnc\n'), (78, 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', ([], {'symbol': "['BRAF', 'ZNF3']"}), False, 'from apyhgnc import apyhgnc\n'), (91, 'apyhgnc.apyhgnc.asearch', 'apyhgnc.asearch', ([], {'symbol': '"""BRAF"""', 'status': '"""Approved"""'}), False, 'from apyhgnc import apyhgnc\n')]