# Path: ogn/parser/aprs_comment/receiver_parser.py
# class ReceiverParser(BaseParser):
#     def __init__(self):
#         self.beacon_type = 'receiver'
#         self.position_pattern = PATTERN_RECEIVER_POSITION_COMMENT
#         self.status_pattern = PATTERN_RECEIVER_STATUS_COMMENT
# 
#     def parse_position(self, aprs_comment):
#         if aprs_comment is None:
#             return {}
#         else:
#             match = self.position_pattern.match(aprs_comment)
#             return {'user_comment': match.group('user_comment') if match.group('user_comment') else None}
# 
#     def parse_status(self, aprs_comment):
#         match = self.status_pattern.match(aprs_comment)
#         result = {
#             'version': match.group('version'),
#             'platform': match.group('platform'),
#             'cpu_load': float(match.group('cpu_load')),
#             'free_ram': float(match.group('ram_free')),
#             'total_ram': float(match.group('ram_total')),
#             'ntp_error': float(match.group('ntp_offset')),
#         }
# 
#         if match.group('ntp_correction'): result['rt_crystal_correction'] = float(match.group('ntp_correction'))
#         if match.group('voltage'): result['voltage'] = float(match.group('voltage'))
#         if match.group('amperage'): result['amperage'] = float(match.group('amperage'))
#         if match.group('cpu_temperature'): result['cpu_temp'] = float(match.group('cpu_temperature'))
#         if match.group('visible_senders'): result['senders_visible'] = int(match.group('visible_senders'))
#         if match.group('senders'): result['senders_total'] = int(match.group('senders'))
#         if match.group('rf_correction_manual'): result['rec_crystal_correction'] = int(match.group('rf_correction_manual'))
#         if match.group('rf_correction_automatic'): result['rec_crystal_correction_fine'] = float(match.group('rf_correction_automatic'))
#         if match.group('signal_quality'): result['rec_input_noise'] = float(match.group('signal_quality'))
#         if match.group('senders_signal_quality'): result['senders_signal'] = float(match.group('senders_signal_quality'))
#         if match.group('senders_messages'): result['senders_messages'] = float(match.group('senders_messages'))
#         if match.group('good_senders_signal_quality'): result['good_senders_signal'] = float(match.group('good_senders_signal_quality'))
#         if match.group('good_senders'): result['good_senders'] = float(match.group('good_senders'))
#         if match.group('good_and_bad_senders'): result['good_and_bad_senders'] = float(match.group('good_and_bad_senders'))
# 
#         return result


import unittest
from ogn.parser.aprs_comment.receiver_parser import ReceiverParser



class TestStringMethods(unittest.TestCase):
    def test_position_comment(self):
        message = ReceiverParser().parse_position("Antenna: chinese, on a pylon, 20 meter above ground")

        self.assertEqual(message['user_comment'], "Antenna: chinese, on a pylon, 20 meter above ground")

    def test_position_comment_empty(self):
        message = ReceiverParser().parse_position("")

        self.assertIsNotNone(message)

    def test_status_comment(self):

# Path: ogn/parser/aprs_comment/receiver_parser.py
# class ReceiverParser(BaseParser):
#     def __init__(self):
#         self.beacon_type = 'receiver'
#         self.position_pattern = PATTERN_RECEIVER_POSITION_COMMENT
#         self.status_pattern = PATTERN_RECEIVER_STATUS_COMMENT
# 
#     def parse_position(self, aprs_comment):
#         if aprs_comment is None:
#             return {}
#         else:
#             match = self.position_pattern.match(aprs_comment)
#             return {'user_comment': match.group('user_comment') if match.group('user_comment') else None}
# 
#     def parse_status(self, aprs_comment):
#         match = self.status_pattern.match(aprs_comment)
#         result = {
#             'version': match.group('version'),
#             'platform': match.group('platform'),
#             'cpu_load': float(match.group('cpu_load')),
#             'free_ram': float(match.group('ram_free')),
#             'total_ram': float(match.group('ram_total')),
#             'ntp_error': float(match.group('ntp_offset')),
#         }
# 
#         if match.group('ntp_correction'): result['rt_crystal_correction'] = float(match.group('ntp_correction'))
#         if match.group('voltage'): result['voltage'] = float(match.group('voltage'))
#         if match.group('amperage'): result['amperage'] = float(match.group('amperage'))
#         if match.group('cpu_temperature'): result['cpu_temp'] = float(match.group('cpu_temperature'))
#         if match.group('visible_senders'): result['senders_visible'] = int(match.group('visible_senders'))
#         if match.group('senders'): result['senders_total'] = int(match.group('senders'))
#         if match.group('rf_correction_manual'): result['rec_crystal_correction'] = int(match.group('rf_correction_manual'))
#         if match.group('rf_correction_automatic'): result['rec_crystal_correction_fine'] = float(match.group('rf_correction_automatic'))
#         if match.group('signal_quality'): result['rec_input_noise'] = float(match.group('signal_quality'))
#         if match.group('senders_signal_quality'): result['senders_signal'] = float(match.group('senders_signal_quality'))
#         if match.group('senders_messages'): result['senders_messages'] = float(match.group('senders_messages'))
#         if match.group('good_senders_signal_quality'): result['good_senders_signal'] = float(match.group('good_senders_signal_quality'))
#         if match.group('good_senders'): result['good_senders'] = float(match.group('good_senders'))
#         if match.group('good_and_bad_senders'): result['good_and_bad_senders'] = float(match.group('good_and_bad_senders'))
# 
#         return result


# Path: tests/parser/test_parse_receiver.py
import unittest
from ogn.parser.aprs_comment.receiver_parser import ReceiverParser




class TestStringMethods(unittest.TestCase):
    def test_position_comment(self):
        message = ReceiverParser().parse_position("Antenna: chinese, on a pylon, 20 meter above ground")

        self.assertEqual(message['user_comment'], "Antenna: chinese, on a pylon, 20 meter above ground")

    def test_position_comment_empty(self):
        message = ReceiverParser().parse_position("")

        self.assertIsNotNone(message)

    def test_status_comment(self):

        message = ReceiverParser().parse_status("v0.2.7.RPI-GPU CPU:0.7 RAM:770.2/968.2MB NTP:1.8ms/-3.3ppm +55.7C 7/8Acfts[1h] RF:+54-1.1ppm/-0.16dB/+7.1dB@10km[19481]/+16.8dB@10km[7/13]")