Beispiel #1
0
    def test_show(self, get_serial_devices, get_usb):
        get_serial_devices.return_value = [
            _Device('/dev/ttyS0'),
            _Device('/dev/ttyS1')
        ]
        get_usb.return_value = [
            # Without manufacturer and product
            Settable(idProduct=1234, idVendor=9999),
            # Without manufacturer
            Settable(idProduct=0x1234,
                     idVendor=0x9876,
                     manufacturer=None,
                     product='Printer'),
            # Complete
            Settable(idProduct=0x1234,
                     idVendor=0x9876,
                     manufacturer='USB',
                     product='Printer')
        ]

        station = self.create_station()
        settings = DeviceSettings(store=self.store,
                                  type=DeviceSettings.SCALE_DEVICE)
        editor = DeviceSettingsEditor(self.store,
                                      model=settings,
                                      station=station)
        self.check_editor(editor, 'editor-devicesetting-show')
Beispiel #2
0
 def test_init_without_station(self, get_active_stations,
                               get_serial_devices):
     get_serial_devices.return_value = [
         _Device('/dev/ttyS0'),
         _Device('/dev/ttyS1')
     ]
     get_active_stations.return_value = []
     editor = DeviceSettingsEditor(self.store)
     self.check_editor(editor, 'editor-devicesetting-without-station')
Beispiel #3
0
 def test_create(self, get_serial_devices):
     get_serial_devices.return_value = [
         _Device('/dev/ttyS0'),
         _Device('/dev/ttyS1')
     ]
     station = self.create_station()
     editor = DeviceSettingsEditor(self.store, station=station)
     editor.type_combo.select_item_by_data(DeviceSettings.SCALE_DEVICE)
     editor.brand_combo.select_item_by_data('toledo')
     self.check_editor(editor, 'editor-devicesetting-create')
Beispiel #4
0
    def test_get_supported_types(self):
        editor = DeviceSettingsEditor(self.store)

        # Scale type
        editor.model.type = DeviceSettings.SCALE_DEVICE
        types = editor._get_supported_types()
        self.assertIn('toledo', types)

        # Non fiscal type
        editor.model.type = DeviceSettings.NON_FISCAL_PRINTER_DEVICE
        types = editor._get_supported_types()
        self.assertIn('epson', types)
        self.assertIn('bematech', types)

        # Unsupported
        editor.model.type = None
        with self.assertRaises(TypeError):
            editor._get_supported_types()
Beispiel #5
0
 def test_init_wrong_station(self):
     station = object()
     with self.assertRaises(TypeError):
         DeviceSettingsEditor(self.store, station=station)