# Path: onix/backend/sql/schema.py
# def set_sqlite_pragma(dbapi_connection, connection_record):
# def _ignore_insert(conn, element, multiparams, params):
# def create_tables(engine):
# 
# Path: onix/backend/sql/dao.py
# class ReportingDAO(_dao.ReportingDAO):
#     def __init__(self, connection):
#     def _filtered_battles(self, month, metagame, min_turns):
#     def get_number_of_battles(self, month, metagame, min_turns=3):
#     def _weighted_players(self, battles, baseline):
#     def get_total_weight(self, month, metagame, baseline=1630., min_turns=3):
#     def _weighted_team_members(self, players, sl_table):
#     def _remove_duplicates(self, team_members):
#     def get_usage_by_species(self, month, metagame, species_lookup,
#                              baseline=1630., min_turns=3):


import pytest
import sqlalchemy as sa
from onix.backend.sql import schema
from onix.backend.sql import dao
                     '(2, "anythinggoes", "2016-08-01", 13, "forfeit"), '
                     '(3, "anythinggoes", "2016-08-07", 26, "forfeit"), '
                     '(4, "ubers", "2016-08-10", 7, "normal"), '
                     '(5, "anythinggoes", "2016-08-13", 38, "normal"), '
                     '(6, "anythinggoes", "2016-08-15", 2, "forfeit"), '
                     '(7, "anythinggoes", "2016-08-31", 68, "normal"), '
                     '(8, "anythinggoes", "2016-09-15", 38, "forfeit")')
        conn.execute('INSERT INTO battle_players '
                     '(bid, side, pid, tid, rpr, rprd) VALUES '
                     '(1, 1, "charley", "03", 1500., 130.), '
                     '(1, 2, "delia", "02", 5000., 25.), '
                     '(2, 1, "alice", "00", 3000., 27.), '
                     '(2, 2, "bob", "01", 1630., 75.), '
                     '(3, 1, "bob", "01", 1630., 63.), '
                     '(3, 2, "eve", "02", 0., 37.), '
                     '(4, 1, "delia", "02", 5000., 25.), '
                     '(4, 2, "eve", "02", 100., 32.), '
                     '(5, 1, "alice", "00", 3000., 25.), '
                     '(5, 2, "eve", "00", 0., 28.), '
                     '(6, 1, "delia", "02", 5000., 25.), '
                     '(6, 2, "bob", "01", 1500., 48.), '
                     '(7, 1, "eve", "03", 1630., 25.), '
                     '(7, 2, "bob", "01", 1630., 33.), '
                     '(8, 1, "charley", "03", NULL, NULL), '
                     '(8, 2, "bob", "01", 2760., 28.)')


@pytest.fixture()
def reporting_dao(engine):
    with engine.connect() as conn:

# Path: onix/backend/sql/schema.py
# def set_sqlite_pragma(dbapi_connection, connection_record):
# def _ignore_insert(conn, element, multiparams, params):
# def create_tables(engine):
# 
# Path: onix/backend/sql/dao.py
# class ReportingDAO(_dao.ReportingDAO):
#     def __init__(self, connection):
#     def _filtered_battles(self, month, metagame, min_turns):
#     def get_number_of_battles(self, month, metagame, min_turns=3):
#     def _weighted_players(self, battles, baseline):
#     def get_total_weight(self, month, metagame, baseline=1630., min_turns=3):
#     def _weighted_team_members(self, players, sl_table):
#     def _remove_duplicates(self, team_members):
#     def get_usage_by_species(self, month, metagame, species_lookup,
#                              baseline=1630., min_turns=3):


# Path: tests/backend/sql/test_dao.py
import pytest
import sqlalchemy as sa
from onix.backend.sql import schema
from onix.backend.sql import dao

                     '(2, "anythinggoes", "2016-08-01", 13, "forfeit"), '
                     '(3, "anythinggoes", "2016-08-07", 26, "forfeit"), '
                     '(4, "ubers", "2016-08-10", 7, "normal"), '
                     '(5, "anythinggoes", "2016-08-13", 38, "normal"), '
                     '(6, "anythinggoes", "2016-08-15", 2, "forfeit"), '
                     '(7, "anythinggoes", "2016-08-31", 68, "normal"), '
                     '(8, "anythinggoes", "2016-09-15", 38, "forfeit")')
        conn.execute('INSERT INTO battle_players '
                     '(bid, side, pid, tid, rpr, rprd) VALUES '
                     '(1, 1, "charley", "03", 1500., 130.), '
                     '(1, 2, "delia", "02", 5000., 25.), '
                     '(2, 1, "alice", "00", 3000., 27.), '
                     '(2, 2, "bob", "01", 1630., 75.), '
                     '(3, 1, "bob", "01", 1630., 63.), '
                     '(3, 2, "eve", "02", 0., 37.), '
                     '(4, 1, "delia", "02", 5000., 25.), '
                     '(4, 2, "eve", "02", 100., 32.), '
                     '(5, 1, "alice", "00", 3000., 25.), '
                     '(5, 2, "eve", "00", 0., 28.), '
                     '(6, 1, "delia", "02", 5000., 25.), '
                     '(6, 2, "bob", "01", 1500., 48.), '
                     '(7, 1, "eve", "03", 1630., 25.), '
                     '(7, 2, "bob", "01", 1630., 33.), '
                     '(8, 1, "charley", "03", NULL, NULL), '
                     '(8, 2, "bob", "01", 2760., 28.)')


@pytest.fixture()
def reporting_dao(engine):
    with engine.connect() as conn:

        yield dao.ReportingDAO(conn)