Ejemplo n.º 1
0
    def test_remove_button(self):
        attribute = self.create_grid_attribute()
        option1 = self.create_attribute_option(grid_attribute=attribute,
                                               description=u'option1')
        option2 = self.create_attribute_option(grid_attribute=attribute,
                                               description=u'option2',
                                               order=2)

        # creating a child product using option2
        options = []
        options.append(option2)
        grid_product = self.create_product(is_grid=True)
        grid_product.add_grid_child(options)

        # Creating the slave
        slave = _GridOptionsSlave(self.store, attribute)
        # At first remove_button should be insensitive
        self.assertNotSensitive(slave.listcontainer, ['remove_button'])

        # changing selection to a option which is not being used
        slave.listcontainer.list.select(option1)
        self.assertSensitive(slave.listcontainer, ['remove_button'])

        # changing selection to a option that is being used
        slave.listcontainer.list.select(option2)
        self.assertNotSensitive(slave.listcontainer, ['remove_button'])
Ejemplo n.º 2
0
    def test_remove_last_option(self, yesno):
        attribute = self.create_grid_attribute()
        option = self.create_attribute_option(grid_attribute=attribute,
                                              description=u'option1')

        # Creating the slave
        slave = _GridOptionsSlave(self.store, attribute)
        # At first remove_button should be insensitive
        self.assertNotSensitive(slave.listcontainer, ['remove_button'])

        # Selecting one option to remove
        slave.listcontainer.list.select(option)
        self.assertSensitive(slave.listcontainer, ['remove_button'])
        yesno.return_value = Gtk.ResponseType.OK
        self.click(slave.listcontainer.remove_button)
        self.assertEqual(len(slave.listcontainer.list), 0)
Ejemplo n.º 3
0
    def test_run_editor(self, run_dialog):
        attribute = self.create_grid_attribute()
        option = self.create_attribute_option(grid_attribute=attribute,
                                              description=u'option1')

        slave = _GridOptionsSlave(self.store, attribute)
        self.assertSensitive(slave.listcontainer, ['add_button'])
        self.click(slave.listcontainer.add_button)
        run_dialog.assert_called_once_with(GridOptionEditor,
                                           store=self.store,
                                           model=None,
                                           attribute=attribute)

        run_dialog.reset_mock()
        slave.listcontainer.list.select(option)
        self.click(slave.listcontainer.edit_button)
        run_dialog.assert_called_once_with(GridOptionEditor,
                                           store=self.store,
                                           model=option,
                                           attribute=attribute)
Ejemplo n.º 4
0
 def test_create(self):
     attribute = self.create_grid_attribute()
     slave = _GridOptionsSlave(self.store, attribute)
     self.check_slave(slave, 'slave-grid-option')