# 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_19():
    line = 'T:706771 AType:19 '
    result = {'tik': 706771, 'atype_id': 19}
    assert parse(line) == result


def test_atype_20():
    line = 'T:2126 AType:20 USERID:3cf05e60-809a-4c12-bfa4-832f6d282f0d USERNICKID:19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'
    result = {'tik': 2126, 'atype_id': 20, 'account_id': '3cf05e60-809a-4c12-bfa4-832f6d282f0d',
              'profile_id': '19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'}
    assert parse(line) == result


def test_atype_21():
    line = 'T:2126 AType:21 USERID:3cf05e60-809a-4c12-bfa4-832f6d282f0d USERNICKID:19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'
    result = {'tik': 2126, 'atype_id': 21, 'account_id': '3cf05e60-809a-4c12-bfa4-832f6d282f0d',
              'profile_id': '19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'}
    assert parse(line) == result


def test_atype_22():
    line = 'T:36160 AType:22 PID:1684580 POS(223718.406, 10.337, 242309.250)'
    result = {'tik': 36160, 'atype_id': 22, 'tank_id': 1684580, 'pos': dict(x=223718.406, y=10.337, z=242309.250)}
    assert parse(line) == result


def test_atype_unknown():
    line = 'T:58 AType:25 VER:17'

# 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_19():
    line = 'T:706771 AType:19 '
    result = {'tik': 706771, 'atype_id': 19}
    assert parse(line) == result


def test_atype_20():
    line = 'T:2126 AType:20 USERID:3cf05e60-809a-4c12-bfa4-832f6d282f0d USERNICKID:19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'
    result = {'tik': 2126, 'atype_id': 20, 'account_id': '3cf05e60-809a-4c12-bfa4-832f6d282f0d',
              'profile_id': '19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'}
    assert parse(line) == result


def test_atype_21():
    line = 'T:2126 AType:21 USERID:3cf05e60-809a-4c12-bfa4-832f6d282f0d USERNICKID:19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'
    result = {'tik': 2126, 'atype_id': 21, 'account_id': '3cf05e60-809a-4c12-bfa4-832f6d282f0d',
              'profile_id': '19ce5f28-1bd6-4116-9e5e-fbe1cb955da3'}
    assert parse(line) == result


def test_atype_22():
    line = 'T:36160 AType:22 PID:1684580 POS(223718.406, 10.337, 242309.250)'
    result = {'tik': 36160, 'atype_id': 22, 'tank_id': 1684580, 'pos': dict(x=223718.406, y=10.337, z=242309.250)}
    assert parse(line) == result


def test_atype_unknown():
    line = 'T:58 AType:25 VER:17'

    with pytest.raises(UnexpectedATypeWarning):
