<commit_before>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4


import unittest
import pygsm


class MockDevice(object):
    pass


class TestIncomingMessage(unittest.TestCase):
    def setUp(self):
        pass
    
    def tearDown(self):
        pass


if __name__ == "__main__":
    unittest.main()<commit_msg>added two unit tests for gsmmodem! both fail!<commit_after>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4


import unittest
import pygsm

from mock.device import MockDevice


class TestIncomingMessage(unittest.TestCase):
    def testEchoOff(self):
        """Checks that GsmModem disables echo at some point
           during boot, to simplify logging and processing."""
        
        class MockEchoDevice(MockDevice):
            def process(self, cmd):
                if cmd == "ATE0":
                    self.echo = False
                    return True
        
        device = MockEchoDevice()
        gsm = pygsm.GsmModem(device=device)
        self.assetEqual(device.echo, False)
    
    
    def testUsefulErrors(self):
        """Checks that GsmModem attempts to enable useful errors
           during boot, to make the errors raised useful to humans.
           Many modems don't support this, but it's very useful."""
        
        class MockUsefulErrorsDevice(MockDevice):
            def __init__(self):
                MockDevice.__init__(self)
                self.useful_errors = False
            
            def process(self, cmd):
                if cmd == "AT+CMEE=1":
                    self.useful_errors = True
                    return True
        
        device = MockUsefulErrorsDevice()
        gsm = pygsm.GsmModem(device=device)
        self.assetEqual(device.useful_errors, True)


if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.08467966573816156, 'fraction_numerical': 0.004456824512534819, 'mean_word_length': 2.018487394957983, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3169752', 'n_tokens_mistral': 531, 'n_tokens_neox': 512, 'n_words': 142}