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


import unittest
import pygsm
import mox

class TestBase(unittest.TestCase):
    mode_map = { 
                'text': 1,
                'pdu': 0 
                }
    
    cmgl_map = {
                'text': '"REC UNREAD"',
                'pdu':'0'
                }
    
    # Some useful constants for the tests
    read_time_out = pygsm.errors.GsmReadTimeoutError(">") 
    rl_args={'read_timeout': mox.IgnoreArg(),
                      'read_term': mox.IgnoreArg()}
    ok = ["","OK"]
    
    def get_mode(self):
        """
        Subclass overrides this to return 'TEXT' or 'PDU'
        
        """
        return None
    
    def setUp(self):
        self.mocker = mox.Mox()
        self.mockDevice = self.mocker.CreateMock(pygsm.devicewrapper.DeviceWrapper)
        
        # verify the config commands
        self.mockDevice.write("ATE0\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mockDevice.write("AT+CMEE=1\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
       
        self.mockDevice.write("AT+WIND=0\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mockDevice.write("AT+CSMS=1\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
         
        # must see command to set PDU mode
        mode_int = self.mode_map[self.get_mode().lower()]
        self.mockDevice.write("AT+CMGF=%d\r" % mode_int)
                              
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mockDevice.write("AT+CNMI=2,2,0,0,0\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        # verify fetch_stored_messages in boot
        cmgl_str = self.cmgl_map[self.get_mode().lower()]
        self.mockDevice.write("AT+CMGL=%s\r" % cmgl_str)
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mocker.ReplayAll()
        self.gsm = pygsm.GsmModem(device=self.mockDevice, mode=self.get_mode())
        
#        self.mocker.VerifyAll()
        self.mocker.ResetAll()
        <commit_msg>Removed commented out line.<commit_after>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4 encoding=utf-8

import unittest
import pygsm
import mox

class TestBase(unittest.TestCase):
    mode_map = { 
                'text': 1,
                'pdu': 0 
                }
    
    cmgl_map = {
                'text': '"REC UNREAD"',
                'pdu':'0'
                }
    
    # Some useful constants for the tests
    read_time_out = pygsm.errors.GsmReadTimeoutError(">") 
    rl_args={'read_timeout': mox.IgnoreArg(),
                      'read_term': mox.IgnoreArg()}
    ok = ["","OK"]
    
    def get_mode(self):
        """
        Subclass overrides this to return 'TEXT' or 'PDU'
        
        """
        return None
    
    def setUp(self):
        self.mocker = mox.Mox()
        self.mockDevice = self.mocker.CreateMock(pygsm.devicewrapper.DeviceWrapper)
        
        # verify the config commands
        self.mockDevice.write("ATE0\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mockDevice.write("AT+CMEE=1\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
       
        self.mockDevice.write("AT+WIND=0\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mockDevice.write("AT+CSMS=1\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
         
        # must see command to set PDU mode
        mode_int = self.mode_map[self.get_mode().lower()]
        self.mockDevice.write("AT+CMGF=%d\r" % mode_int)
                              
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mockDevice.write("AT+CNMI=2,2,0,0,0\r")
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        # verify fetch_stored_messages in boot
        cmgl_str = self.cmgl_map[self.get_mode().lower()]
        self.mockDevice.write("AT+CMGL=%s\r" % cmgl_str)
        self.mockDevice.read_lines(**self.rl_args).AndReturn(self.ok)
        
        self.mocker.ReplayAll()
        self.gsm = pygsm.GsmModem(device=self.mockDevice, mode=self.get_mode())
        
        self.mocker.ResetAll()
        
{'fraction_non_alphanumeric': 0.13396268824454935, 'fraction_numerical': 0.006967857945605754, 'mean_word_length': 1.9966329966329965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1828671', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1485, 'n_words': 201}