# Path: ogn/parser/utils.py
# FPM_TO_MS = FEETS_TO_METER / 60     # ratio fpm to m/s
# 
# HPM_TO_DEGS = 180 / 60              # ratio between half turn per minute and degrees/s
# 
# Path: ogn/parser/aprs_comment/naviter_parser.py
# class NaviterParser(BaseParser):
#     def __init__(self):
#         self.beacon_type = 'naviter'
#         self.position_pattern = PATTERN_NAVITER_POSITION_COMMENT
# 
#     def parse_position(self, aprs_comment):
#         match = self.position_pattern.match(aprs_comment)
#         return {'stealth': (int(match.group('details'), 16) & 0b1000000000000000) >> 15 == 1,
#                 'do_not_track': (int(match.group('details'), 16) & 0b0100000000000000) >> 14 == 1,
#                 'aircraft_type': (int(match.group('details'), 16) & 0b0011110000000000) >> 10,
#                 'address_type': (int(match.group('details'), 16) & 0b0000001111110000) >> 4,
#                 'reserved': (int(match.group('details'), 16) & 0b0000000000001111),
#                 'address': match.group('address'),
#                 'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None,
#                 'turn_rate': float(match.group('turn_rate')) * HPM_TO_DEGS if match.group('turn_rate') else None}


import unittest
from ogn.parser.utils import FPM_TO_MS, HPM_TO_DEGS
from ogn.parser.aprs_comment.naviter_parser import NaviterParser



class TestStringMethods(unittest.TestCase):
    def test_OGNAVI_1(self):
        message = NaviterParser().parse_position("id0440042121 +123fpm +0.5rot")

        # id0440042121 == 0b0000 0100 0100 0000 0000 0100 0010 0001 0010 0001
        # bit 0: stealth mode
        # bit 1: do not track mode
        # bits 2-5: aircraft type
        # bits 6-11: address type (namespace is extended from 2 to 6 bits to avoid collisions with other tracking providers)
        # bits 12-15: reserved for use at a later time
        # bits 16-39: device id (24-bit device identifier, same as in APRS header)
        self.assertEqual(message['stealth'], False)

# Path: ogn/parser/utils.py
# FPM_TO_MS = FEETS_TO_METER / 60     # ratio fpm to m/s
# 
# HPM_TO_DEGS = 180 / 60              # ratio between half turn per minute and degrees/s
# 
# Path: ogn/parser/aprs_comment/naviter_parser.py
# class NaviterParser(BaseParser):
#     def __init__(self):
#         self.beacon_type = 'naviter'
#         self.position_pattern = PATTERN_NAVITER_POSITION_COMMENT
# 
#     def parse_position(self, aprs_comment):
#         match = self.position_pattern.match(aprs_comment)
#         return {'stealth': (int(match.group('details'), 16) & 0b1000000000000000) >> 15 == 1,
#                 'do_not_track': (int(match.group('details'), 16) & 0b0100000000000000) >> 14 == 1,
#                 'aircraft_type': (int(match.group('details'), 16) & 0b0011110000000000) >> 10,
#                 'address_type': (int(match.group('details'), 16) & 0b0000001111110000) >> 4,
#                 'reserved': (int(match.group('details'), 16) & 0b0000000000001111),
#                 'address': match.group('address'),
#                 'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None,
#                 'turn_rate': float(match.group('turn_rate')) * HPM_TO_DEGS if match.group('turn_rate') else None}


# Path: tests/parser/test_parse_naviter.py
import unittest
from ogn.parser.utils import FPM_TO_MS, HPM_TO_DEGS
from ogn.parser.aprs_comment.naviter_parser import NaviterParser




class TestStringMethods(unittest.TestCase):
    def test_OGNAVI_1(self):
        message = NaviterParser().parse_position("id0440042121 +123fpm +0.5rot")

        # id0440042121 == 0b0000 0100 0100 0000 0000 0100 0010 0001 0010 0001
        # bit 0: stealth mode
        # bit 1: do not track mode
        # bits 2-5: aircraft type
        # bits 6-11: address type (namespace is extended from 2 to 6 bits to avoid collisions with other tracking providers)
        # bits 12-15: reserved for use at a later time
        # bits 16-39: device id (24-bit device identifier, same as in APRS header)
        self.assertEqual(message['stealth'], False)

        self.assertEqual(message['do_not_track'], False)