예제 #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_two_device_and_port( self, config ):
        N = OneInN()

        listeners = []
        data = {}
        device1 = '0x13a200409029bf'
        device2 = '0x13a200408cccc3'
        port = 'adc-1'

        data[Constants.DataPacket.device] = device1
        data[Constants.DataPacket.port] = port
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device1][port], 1 )

        data[Constants.DataPacket.device] = device2
        data[Constants.DataPacket.port] = port
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device2][port], 1 )

        data[Constants.DataPacket.device] = device1
        data[Constants.DataPacket.port] = port
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device1][port], 2 )

        data[Constants.DataPacket.device] = device1
        data[Constants.DataPacket.port] = port
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device1][port], 3 )

        N = None
예제 #3
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 )
예제 #4
0
    def test_oneInN_with_one_device_and_port( self, config ):
        N = OneInN()

        N.config = {'0x13a200409029bf': {'adc-1': '2'}, '0x13a200408cccc3': {'adc-0': '2', 'adc-1': '5'}}
        listeners = []
        data = {}
        device = '0x13a200409029bf'
        port = 'adc-1'
        data[Constants.DataPacket.device] = device
        data[Constants.DataPacket.port] = port
        N.step( 1, data, listeners )
        self.assertEqual( N.count[device][port], 1 )

        N.step( 1, data, listeners )
        self.assertEqual( N.count[device][port], 2 )

        N.step( 1, data, listeners )
        self.assertEqual( N.count[device][port], 3 )

        N = None