コード例 #1
0
    def test_oneInN_with_no_device_in_count_dict( self, configuration ):
        N = OneInN()
        N.config = {'0x13a200409029bf': {'adc-1': '2'}, '0x13a200408cccc3': {'adc-0': '2', 'adc-1': '5'}}
        N.count = {}
        listeners = ['a', 'b', 'c']
        data = {}
        device = '0x13a200409029bf'
        port = 'adc-1'

        data[Constants.DataPacket.port] = port
        data[Constants.DataPacket.device] = device
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device][port], 1 )
コード例 #2
0
    def test_oneInN_with_one_device_in_count_dict_that_is_not_the_same( self, configuration ):
        device0 = 'device0'
        device1 = 'device1'
        port0 = 'port0'
        port1 = 'port1'

        N = OneInN()
        N.config = {device0: {port1: '2', port0: 10}, device1: {port0: '2', port1: '5'}}
        N.count = {device1: {port1: 10}}
        listeners = ['a', 'b', 'c']
        data = {}

        data[Constants.DataPacket.port] = port0
        data[Constants.DataPacket.device] = device0
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device0][port0], 1 )
        self.assertEqual( N.count[device1][port1], 10 )
コード例 #3
0
    def test_oneInN_with_no_device_in_count_dict( self, config ):
        N = OneInN()
        Common.send = Mock()
        GetDateTime.isoformat = Mock()
        GetDateTime.isoformat.return_value = '123'
        N.config = {'0x13a200409029bf': {'adc-1': '2'}, '0x13a200408cccc3': {'adc-0': '2', 'adc-1': '5'}}
        N.count = {}
        listeners = ['a', 'b', 'c']
        data = {}
        device = '0x13a200409029bf'
        port = 'adc-1'

        data[Constants.DataPacket.port] = port
        data[Constants.DataPacket.device] = device
        N.substep( 1, data, listeners )
        self.assertEqual( N.count[device][port], 1 )
        self.assertEqual( N.errors, 0 )
        self.assertEqual( N.counter, 1 )
コード例 #4
0
    def test_oneInN_with_one_device_and_other_port_in_count_dict( self, send, configuration ):
        N = OneInN()
        GetDateTime.isoformat = Mock()
        GetDateTime.isoformat.return_value = '123'
        N.config = {'0x13a200409029bf': {'adc-1': '2', 'adc-0': 10}, '0x13a200408cccc3': {'adc-0': '2', 'adc-1': '5'}}
        N.count = {'0x13a200409029bf': {'adc-0': 10}}
        listeners = ['a', 'b', 'c']
        data = {}
        device0 = '0x13a200409029bf'
        device1 = '0x13a200408cccc3'
        port0 = 'adc-0'
        port1 = 'adc-1'

        data[Constants.DataPacket.port] = port1
        data[Constants.DataPacket.device] = device0
        N.substep( 1, data, listeners )
        self.assertEqual( N.count[device0][port0], 10 )
        self.assertEqual( N.count[device0][port1], 1 )
        self.assertEqual( N.errors, 0 )
        self.assertEqual( N.last_error_time, None )
        self.assertEqual( N.counter, 1 )
コード例 #5
0
    def test_oneInN_with_one_device_in_count_dict_that_is_not_the_same( self, config ):
        device0 = 'device0'
        device1 = 'device1'
        port0 = 'port0'
        port1 = 'port1'

        N = OneInN()
        Common.send = Mock()
        GetDateTime.isoformat = Mock()
        GetDateTime.isoformat.return_value = '123'
        N.config = {device0: {port1: '2', port0: 10}, device1: {port0: '2', port1: '5'}}
        N.count = {device1: {port1: 10}}
        listeners = ['a', 'b', 'c']
        data = {}

        data[Constants.DataPacket.port] = port0
        data[Constants.DataPacket.device] = device0
        N.substep( 1, data, listeners )
        self.assertEqual( N.count[device0][port0], 1 )
        self.assertEqual( N.count[device1][port1], 10 )
        self.assertEqual( N.errors, 0 )
        self.assertEqual( N.counter, 1 )