# Path: src/mission_report/parse_mission_log_line.py
# def parse(line):
#     """
#     :type line: str
#     :rtype: dict | None
#     """
#     line = unicodedata.normalize('NFKD', line)
#     atype_id = int(line.partition('AType:')[2][:2])
#     if 0 <= atype_id <= 22:
#         data = atype_handlers[atype_id].match(line.strip()).groupdict()
#         data['atype_id'] = atype_id
#         for key, value in list(data.items()):
#             if key in params_handlers:
#                 data[key] = params_handlers[key](value)
#         return data
#     else:
#         raise UnexpectedATypeWarning
# 
# class UnexpectedATypeWarning(Warning):
#     pass


from datetime import datetime
from ..parse_mission_log_line import parse, UnexpectedATypeWarning
import pytest





def test_atype_0():
    line = ('T:0 AType:0 GDate:1942.9.19 GTime:14:0:0 MFile:Multiplayer/Dogfight\_gen.msnbin MID: GType:2 '
            'CNTRS:0:0,101:1,201:2 SETTS:000000000010000100000000110 MODS:0 PRESET:0 AQMID:0 ROUNDS: 1 POINTS: 15000')
    result = {'tik': 0, 'atype_id': 0, 'date': datetime(1942, 9, 19, 14),
              'file_path': 'Multiplayer/Dogfight\_gen.msnbin', 'game_type_id': 2,
              'countries': {0: 0, 201: 2,  101: 1},
              'settings': (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0),
              'mods': False, 'preset_id': 0}

# Path: src/mission_report/parse_mission_log_line.py
# def parse(line):
#     """
#     :type line: str
#     :rtype: dict | None
#     """
#     line = unicodedata.normalize('NFKD', line)
#     atype_id = int(line.partition('AType:')[2][:2])
#     if 0 <= atype_id <= 22:
#         data = atype_handlers[atype_id].match(line.strip()).groupdict()
#         data['atype_id'] = atype_id
#         for key, value in list(data.items()):
#             if key in params_handlers:
#                 data[key] = params_handlers[key](value)
#         return data
#     else:
#         raise UnexpectedATypeWarning
# 
# class UnexpectedATypeWarning(Warning):
#     pass


# Path: src/mission_report/tests/test_parse_mission_log_line.py
from datetime import datetime
from ..parse_mission_log_line import parse, UnexpectedATypeWarning
import pytest





def test_atype_0():
    line = ('T:0 AType:0 GDate:1942.9.19 GTime:14:0:0 MFile:Multiplayer/Dogfight\_gen.msnbin MID: GType:2 '
            'CNTRS:0:0,101:1,201:2 SETTS:000000000010000100000000110 MODS:0 PRESET:0 AQMID:0 ROUNDS: 1 POINTS: 15000')
    result = {'tik': 0, 'atype_id': 0, 'date': datetime(1942, 9, 19, 14),
              'file_path': 'Multiplayer/Dogfight\_gen.msnbin', 'game_type_id': 2,
              'countries': {0: 0, 201: 2,  101: 1},
              'settings': (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0),
              'mods': False, 'preset_id': 0}

    assert parse(line) == result
