# Path: onix/backend/sql/sinks.py
# def compute_tid(team, sanitizer=None):
#     """
#     Computes the Team ID for the given group of movesets
# 
#     Args:
#         team (:obj:`iterable` of :obj:`Moveset` or :obj:`str`) :
#             the team for which to compute the TID, represented either by their
#             movesets or by their SIDs
#         sanitizer (:obj:`onix.utilities.Sanitizer`, optional):
#             if no sanitizer is provided, movesets are assumed to be already
#             sanitized. Otherwise, the provided ``Sanitizer`` is used to sanitize
#             the movesets.
# 
#     Returns:
#         str: the corresponding Team ID
# 
#     Examples:
#         >>> from onix.model import Moveset, Forme, PokeStats
#         >>> from onix.backend.sql.sinks import compute_tid
#         >>> delphox = Moveset([Forme('delphox', 'magician',
#         ...                    PokeStats(282, 158, 222, 257, 220, 265))],
#         ...                   'f', 'lifeorb', ['calmmind', 'psychic'], 100, 255)
#         >>> ditto = Moveset([Forme('ditto', 'imposter',
#         ...                  PokeStats(259, 164, 98, 134, 126, 123))],
#         ...                  'u', 'focussash', ['transform'], 100, 255)
#         >>> print(compute_tid([delphox, ditto])) #doctest: +ELLIPSIS
#         4e49b0eb...
#     """
#     if isinstance(team[0], Moveset):
#         sids = [compute_sid(moveset, sanitizer) for moveset in team]
#     elif isinstance(team[0], str):
#         sids = team
#     else:
#         raise TypeError('team is neither an iterable of movesets nor SIDs')
#     sids = sorted(sids)
#     team_hash = hashlib.sha512(repr(sids).encode('utf-8')).hexdigest()
# 
#     # may eventually want to truncate hash, e.g.
#     # team_hash = team_hash[:16]
# 
#     return team_hash
# 
# Path: onix/contexts.py
# class Context(object):
# class ResourceMissingError(Exception):
#     def __init__(self, **resources):
#     def __init__(self, resource):
# def require(context, *resources):
# def _get_context(commit, force_refresh):
# def get_standard_context(force_refresh=False):
# def get_historical_context(timestamp):
# 
# Path: onix/collection/log_reader.py
# class ParsingError(Exception):
# class LogReader(with_metaclass(abc.ABCMeta, object)):
# class JsonFileLogReader(LogReader):
#     def __init__(self, log_ref, message):
# def get_all_formes(species, ability, item, moves,
#                    context, hackmons=False, any_ability=False):
# def rating_dict_to_model(rating_dict):
# def normalize_hidden_power(moves, ivs):
#     def __init__(self, context):
#     def _parse_log(self, log_ref):
#     def parse_log(self, log_ref):
#     def _parse_moveset(self, moveset_dict, hackmons, any_ability,
#                        mega_rayquaza_allowed, default_level):
#     def __init__(self, context):
#     def _parse_log(self, log_ref):
# 
# Path: onix/collection/log_processor.py
# class LogProcessor(object):
#     def __init__(self, moveset_sink, battle_info_sink, battle_sink,
#                  force_context_refresh=False):
#     def _get_log_reader(self, log_ref):
#     def process_logs(self, logs, ref_type='folder', error_handling='raise'):
#     def _process_single_log(self, log_ref):
# 
# Path: onix/collection/sinks.py
# class _Sink(with_metaclass(abc.ABCMeta, object)):
# class MovesetSink(_Sink):
# class BattleInfoSink(_Sink):
# class BattleSink(_Sink):
#     def flush(self):
#     def close(self):
#     def __enter__(self):
#     def __exit__(self, *exc):
#     def store_movesets(self, movesets):
#     def store_battle_info(self, battle_info):
#     def store_battle(self, battle):
# 
# Path: onix/scripts/log_generator.py
# def _generate_random_ev_list():
# def generate_pokemon(species, context,
#                      level=100, hackmons=False, any_ability=False):
# def generate_player(name, **ratings):
# def generate_log(players, teams, turns=None, end_type=None):


import json
import pytest
from collections import defaultdict
from onix.backend.sql.sinks import compute_tid
from onix import contexts
from onix.collection import log_reader as lr
from onix.collection import log_processor as lp
from onix.collection import sinks
from onix.scripts import log_generator as lg
        self.tids = set()
        self.battles = defaultdict(set)

    def store_battle_info(self, battle_info):

        self.pids.update([player.id for player in battle_info.players])
        self.tids.update([compute_tid(team) for team in battle_info.slots])
        self.battles[battle_info.format].add(battle_info.id)

    def flush(self):
        pass

    def close(self):
        self.flush()


@pytest.fixture()
def moveset_sink():
    with StumpMovesetSink() as moveset_sink:
        yield moveset_sink


@pytest.fixture()
def battle_info_sink():
    with StumpBattleInfoSink() as battle_info_sink:
        yield battle_info_sink


@pytest.fixture()
def p(moveset_sink, battle_info_sink):

# Path: onix/backend/sql/sinks.py
# def compute_tid(team, sanitizer=None):
#     """
#     Computes the Team ID for the given group of movesets
# 
#     Args:
#         team (:obj:`iterable` of :obj:`Moveset` or :obj:`str`) :
#             the team for which to compute the TID, represented either by their
#             movesets or by their SIDs
#         sanitizer (:obj:`onix.utilities.Sanitizer`, optional):
#             if no sanitizer is provided, movesets are assumed to be already
#             sanitized. Otherwise, the provided ``Sanitizer`` is used to sanitize
#             the movesets.
# 
#     Returns:
#         str: the corresponding Team ID
# 
#     Examples:
#         >>> from onix.model import Moveset, Forme, PokeStats
#         >>> from onix.backend.sql.sinks import compute_tid
#         >>> delphox = Moveset([Forme('delphox', 'magician',
#         ...                    PokeStats(282, 158, 222, 257, 220, 265))],
#         ...                   'f', 'lifeorb', ['calmmind', 'psychic'], 100, 255)
#         >>> ditto = Moveset([Forme('ditto', 'imposter',
#         ...                  PokeStats(259, 164, 98, 134, 126, 123))],
#         ...                  'u', 'focussash', ['transform'], 100, 255)
#         >>> print(compute_tid([delphox, ditto])) #doctest: +ELLIPSIS
#         4e49b0eb...
#     """
#     if isinstance(team[0], Moveset):
#         sids = [compute_sid(moveset, sanitizer) for moveset in team]
#     elif isinstance(team[0], str):
#         sids = team
#     else:
#         raise TypeError('team is neither an iterable of movesets nor SIDs')
#     sids = sorted(sids)
#     team_hash = hashlib.sha512(repr(sids).encode('utf-8')).hexdigest()
# 
#     # may eventually want to truncate hash, e.g.
#     # team_hash = team_hash[:16]
# 
#     return team_hash
# 
# Path: onix/contexts.py
# class Context(object):
# class ResourceMissingError(Exception):
#     def __init__(self, **resources):
#     def __init__(self, resource):
# def require(context, *resources):
# def _get_context(commit, force_refresh):
# def get_standard_context(force_refresh=False):
# def get_historical_context(timestamp):
# 
# Path: onix/collection/log_reader.py
# class ParsingError(Exception):
# class LogReader(with_metaclass(abc.ABCMeta, object)):
# class JsonFileLogReader(LogReader):
#     def __init__(self, log_ref, message):
# def get_all_formes(species, ability, item, moves,
#                    context, hackmons=False, any_ability=False):
# def rating_dict_to_model(rating_dict):
# def normalize_hidden_power(moves, ivs):
#     def __init__(self, context):
#     def _parse_log(self, log_ref):
#     def parse_log(self, log_ref):
#     def _parse_moveset(self, moveset_dict, hackmons, any_ability,
#                        mega_rayquaza_allowed, default_level):
#     def __init__(self, context):
#     def _parse_log(self, log_ref):
# 
# Path: onix/collection/log_processor.py
# class LogProcessor(object):
#     def __init__(self, moveset_sink, battle_info_sink, battle_sink,
#                  force_context_refresh=False):
#     def _get_log_reader(self, log_ref):
#     def process_logs(self, logs, ref_type='folder', error_handling='raise'):
#     def _process_single_log(self, log_ref):
# 
# Path: onix/collection/sinks.py
# class _Sink(with_metaclass(abc.ABCMeta, object)):
# class MovesetSink(_Sink):
# class BattleInfoSink(_Sink):
# class BattleSink(_Sink):
#     def flush(self):
#     def close(self):
#     def __enter__(self):
#     def __exit__(self, *exc):
#     def store_movesets(self, movesets):
#     def store_battle_info(self, battle_info):
#     def store_battle(self, battle):
# 
# Path: onix/scripts/log_generator.py
# def _generate_random_ev_list():
# def generate_pokemon(species, context,
#                      level=100, hackmons=False, any_ability=False):
# def generate_player(name, **ratings):
# def generate_log(players, teams, turns=None, end_type=None):


# Path: tests/collection/test_log_processor.py
import json
import pytest
from collections import defaultdict
from onix.backend.sql.sinks import compute_tid
from onix import contexts
from onix.collection import log_reader as lr
from onix.collection import log_processor as lp
from onix.collection import sinks
from onix.scripts import log_generator as lg

        self.tids = set()
        self.battles = defaultdict(set)

    def store_battle_info(self, battle_info):

        self.pids.update([player.id for player in battle_info.players])
        self.tids.update([compute_tid(team) for team in battle_info.slots])
        self.battles[battle_info.format].add(battle_info.id)

    def flush(self):
        pass

    def close(self):
        self.flush()


@pytest.fixture()
def moveset_sink():
    with StumpMovesetSink() as moveset_sink:
        yield moveset_sink


@pytest.fixture()
def battle_info_sink():
    with StumpBattleInfoSink() as battle_info_sink:
        yield battle_info_sink


@pytest.fixture()
def p(moveset_sink, battle_info_sink):

    return lp.LogProcessor(moveset_sink, battle_info_sink, None)