Beispiel #1
0
    def test_create_package_product(self, run_dialog):
        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.package.set_active(True)
        self.click(wizard.next_button)

        # ProductEditor step
        editor_step = wizard.get_current_step()
        # Checking that the slave is attached
        self.assertEquals(hasattr(editor_step.slave, 'package_slave'), True)

        # Package slave
        package_slave = editor_step.slave.get_slave('Pack content')
        self.assertNotSensitive(package_slave, ['add_button', 'remove_button',
                                                'edit_button'])

        package_slave.component_combo.select_item_by_position(0)
        selected = package_slave.component_combo.get_selected()
        temp = TemporaryProductComponent(product=package_slave._product,
                                         component=selected)
        # After select a component add button will be sensitive
        self.assertSensitive(package_slave, ['add_button'])
        # And the other remain not sensitive
        self.assertNotSensitive(package_slave, ['remove_button', 'edit_button'])
        run_dialog.return_value = temp
        self.click(package_slave.add_button)

        args, kwargs = run_dialog.call_args
        self.assertEquals(args[0], ProductPackageComponentEditor)
        self.assertTrue(isinstance(args[2], StoqlibStore))
        self.assertTrue(isinstance(args[3], TemporaryProductComponent))
        self.assertTrue(hasattr(args[3], 'product'))
        self.assertTrue(hasattr(args[3], 'component'))
        self.assertTrue(hasattr(args[3], 'quantity'))
        self.assertTrue(hasattr(args[3], 'design_reference'))
Beispiel #2
0
    def test_create_package_product(self, run_dialog):
        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.package.set_active(True)
        self.click(wizard.next_button)

        # ProductEditor step
        editor_step = wizard.get_current_step()
        # Checking that the slave is attached
        self.assertEquals(hasattr(editor_step.slave, 'package_slave'), True)

        # Package slave
        package_slave = editor_step.slave.get_slave('Pack content')
        self.assertNotSensitive(package_slave, ['add_button', 'remove_button',
                                                'edit_button'])

        package_slave.component_combo.select_item_by_position(0)
        selected = package_slave.component_combo.get_selected()
        temp = TemporaryProductComponent(product=package_slave._product,
                                         component=selected)
        # After select a component add button will be sensitive
        self.assertSensitive(package_slave, ['add_button'])
        # And the other remain not sensitive
        self.assertNotSensitive(package_slave, ['remove_button', 'edit_button'])
        run_dialog.return_value = temp
        self.click(package_slave.add_button)

        args, kwargs = run_dialog.call_args
        self.assertEquals(args[0], ProductPackageComponentEditor)
        self.assertTrue(isinstance(args[2], StoqlibStore))
        self.assertTrue(isinstance(args[3], TemporaryProductComponent))
        self.assertTrue(hasattr(args[3], 'product'))
        self.assertTrue(hasattr(args[3], 'component'))
        self.assertTrue(hasattr(args[3], 'quantity'))
        self.assertTrue(hasattr(args[3], 'design_reference'))
 def test_create_without_group(self, warning):
     wizard = ProductCreateWizard(self.store)
     type_step = wizard.get_current_step()
     type_step.grid.set_active(True)
     self.click(wizard.next_button)
     warning.assert_called_once_with("You need to register an attribute group first")
     # Checking that are still on the same step after the warning
     self.assertEquals(wizard.get_current_step(), type_step)
Beispiel #4
0
 def test_create_without_group(self, warning):
     wizard = ProductCreateWizard(self.store)
     type_step = wizard.get_current_step()
     type_step.grid.set_active(True)
     self.click(wizard.next_button)
     warning.assert_called_once_with("You need to register an attribute group first")
     # Checking that are still on the same step after the warning
     self.assertEquals(wizard.get_current_step(), type_step)
    def test_create_grid_product(self, warning):
        attribute_group = self.create_attribute_group()
        grid_attribute = self.create_grid_attribute(attribute_group=attribute_group, description=u"attr 1")
        grid_attribute2 = self.create_grid_attribute(attribute_group=attribute_group, description=u"attr 2")
        self.create_attribute_option(grid_attribute=grid_attribute, description=u"option for attr 1", order=1)
        self.create_attribute_option(grid_attribute=grid_attribute2, description=u"option for attr 2", order=2)

        # Creating the wizard
        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        # ProductAttributeEditorStep
        attribute_step = wizard.get_current_step()
        # Testing simulating combo selection change to cover everything
        attribute_step.slave.attribute_group_combo.select(attribute_group)
        attribute_step.slave.attribute_group_combo.select(None)
        # Selecting the attribute_group on the combo
        attribute_step.slave.attribute_group_combo.select(attribute_group)
        # Set to active all grid_attributes for that group
        for attribute in attribute_step.slave._widgets.keys():
            self.assertEquals(attribute.get_sensitive(), True)
            attribute.set_active(True)
        self.click(wizard.next_button)

        # ProductEditorStep
        editor_step = wizard.get_current_step()
        # Getting ProductGridSlave
        grid_slave = editor_step.slave.get_slave("Grid")
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)

        # Trying add a child without description
        for combo in grid_slave._widgets.values():
            # Position 0 (zero) is empty
            combo.select_item_by_position(1)
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), True)
        self.click(grid_slave.add_product_button)
        warning.assert_called_once_with("You should fill the description first")

        # Filling the description and try again
        editor_step.slave.description.update("grid test")
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), True)
        self.click(grid_slave.add_product_button)
        # Testing the sensitivity right after adding a child
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)

        # One combo not filled with an valid option
        combo = grid_slave._widgets.values()[0]
        # Position 0 (zero) is empty
        combo.select_item_by_position(0)
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)

        # Trying add a child with exactly the same attribute_option
        for combo in grid_slave._widgets.values():
            combo.select_item_by_position(1)
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)
Beispiel #6
0
    def test_create_inactive_group(self):
        inactive_group = self.create_attribute_group()
        inactive_group.is_active = False
        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)
        attribute_step = wizard.get_current_step()

        groups = attribute_step.slave.attribute_group
        for combo_model in groups.get_model_items():
            # The inactive group should not be shown on combo
            self.assertNotEquals(combo_model, inactive_group.description)
    def test_create_inactive_group(self):
        inactive_group = self.create_attribute_group()
        inactive_group.is_active = False
        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)
        attribute_step = wizard.get_current_step()

        groups = attribute_step.slave.attribute_group_combo
        for combo_model in groups.get_model_items():
            # The inactive group should not be shown on combo
            self.assertNotEquals(combo_model, inactive_group.description)
    def test_create_inactive_attribute(self):
        attribute_group = self.create_attribute_group()
        attribute = self.create_grid_attribute(attribute_group=attribute_group)
        attribute.is_active = False

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        attribute_step.slave.attribute_group_combo.select_item_by_data(attribute_group)
        # Inactive attributes should not be shown
        self.assertEquals(attribute_step.slave._widgets, {})
Beispiel #9
0
    def test_create_inactive_attribute(self):
        attribute_group = self.create_attribute_group()
        attribute = self.create_grid_attribute(attribute_group=attribute_group)
        attribute.is_active = False

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        attribute_step.slave.attribute_group.select_item_by_data(attribute_group)
        # Inactive attributes should not be shown
        self.assertEquals(attribute_step.slave._widgets, {})
Beispiel #10
0
    def test_create_with_inactive_option(self):
        attribute_group = self.create_attribute_group()
        attribute = self.create_grid_attribute(attribute_group=attribute_group)
        option = self.create_attribute_option(grid_attribute=attribute)
        option.is_active = False

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        attribute_step.slave.attribute_group_combo.select_item_by_data(attribute_group)
        for check_box in attribute_step.slave._widgets.keys():
            self.assertEquals(check_box.get_sensitive(), False)
Beispiel #11
0
    def test_create_with_inactive_option(self):
        attribute_group = self.create_attribute_group()
        attribute = self.create_grid_attribute(attribute_group=attribute_group)
        option = self.create_attribute_option(grid_attribute=attribute)
        option.is_active = False

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        attribute_step.slave.attribute_group.select_item_by_data(attribute_group)
        for check_box in attribute_step.slave._widgets.keys():
            self.assertEquals(check_box.get_sensitive(), False)
Beispiel #12
0
    def test_create_with_attribute_not_selected(self, warning):
        attribute_group = self.create_attribute_group()
        self.create_grid_attribute(attribute_group=attribute_group)

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        self.click(wizard.next_button)
        warning.reset_mock()
        # Selecting a group with a GridAttribute
        attribute_step.slave.attribute_group_combo.select_item_by_data(attribute_group)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")
Beispiel #13
0
    def test_create_with_attribute_not_selected(self, warning):
        attribute_group = self.create_attribute_group()
        self.create_grid_attribute(attribute_group=attribute_group)

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        self.click(wizard.next_button)
        warning.reset_mock()
        # Selecting a group with a GridAttribute
        attribute_step.slave.attribute_group.select_item_by_data(attribute_group)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")
Beispiel #14
0
    def test_create_without_attribute(self, warning):
        attribute_group = self.create_attribute_group()

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        self.click(wizard.next_button)
        # Testing without selecting a group
        warning.assert_called_once_with("You should select an attribute first")
        # Checking that we are in the same step after the warning
        self.assertEquals(wizard.get_current_step(), attribute_step)

        warning.reset_mock()
        # Selecting a group but it doesnt have a GridAttribute
        attribute_step.slave.attribute_group_combo.select_item_by_data(attribute_group)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")
Beispiel #15
0
    def test_create_without_attribute(self, warning):
        attribute_group = self.create_attribute_group()

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        self.click(wizard.next_button)
        # Testing without selecting a group
        warning.assert_called_once_with("You should select an attribute first")
        # Checking that we are in the same step after the warning
        self.assertEquals(wizard.get_current_step(), attribute_step)

        warning.reset_mock()
        # Selecting a group but it doesnt have a GridAttribute
        attribute_step.slave.attribute_group.select_item_by_data(attribute_group)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")
Beispiel #16
0
    def test_create_with_attribute_without_option(self, warning):
        attribute_group = self.create_attribute_group()
        self.create_grid_attribute(attribute_group=attribute_group)

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        self.click(wizard.next_button)
        warning.reset_mock()
        # Selecting a group with a GridAttribute
        attribute_step.slave.attribute_group.select_item_by_data(attribute_group)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")

        warning.reset_mock()
        # At this point we dont have any attribute_option for grid_attribute
        for i in attribute_step.slave._widgets.keys():
            self.assertEquals(i.get_sensitive(), False)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")
Beispiel #17
0
    def test_create_with_attribute_without_option(self, warning):
        attribute_group = self.create_attribute_group()
        self.create_grid_attribute(attribute_group=attribute_group)

        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        attribute_step = wizard.get_current_step()
        self.click(wizard.next_button)
        warning.reset_mock()
        # Selecting a group with a GridAttribute
        attribute_step.slave.attribute_group_combo.select_item_by_data(attribute_group)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")

        warning.reset_mock()
        # At this point we dont have any attribute_option for grid_attribute
        for i in attribute_step.slave._widgets.keys():
            self.assertEquals(i.get_sensitive(), False)
        self.click(wizard.next_button)
        warning.assert_called_once_with("You should select an attribute first")
Beispiel #18
0
    def test_create_grid_product(self, warning):
        attribute_group = self.create_attribute_group()
        grid_attribute = self.create_grid_attribute(
            attribute_group=attribute_group, description=u'attr 1')
        grid_attribute2 = self.create_grid_attribute(
            attribute_group=attribute_group, description=u'attr 2')
        self.create_attribute_option(grid_attribute=grid_attribute,
                                     description=u'option for attr 1',
                                     order=1)
        self.create_attribute_option(grid_attribute=grid_attribute2,
                                     description=u'option for attr 2',
                                     order=2)

        # Creating the wizard
        wizard = ProductCreateWizard(self.store)
        type_step = wizard.get_current_step()
        type_step.grid.set_active(True)
        self.click(wizard.next_button)

        # ProductAttributeEditorStep
        attribute_step = wizard.get_current_step()
        # Testing simulating combo selection change to cover everything
        attribute_step.slave.attribute_group.select(attribute_group)
        attribute_step.slave.attribute_group.select(None)
        # Selecting the attribute_group on the combo
        attribute_step.slave.attribute_group.select(attribute_group)
        # Set to active all grid_attributes for that group
        for attribute in attribute_step.slave._widgets.keys():
            self.assertEquals(attribute.get_sensitive(), True)
            attribute.set_active(True)
        self.click(wizard.next_button)

        # ProductEditorStep
        editor_step = wizard.get_current_step()
        # Getting ProductGridSlave
        grid_slave = editor_step.slave.get_slave('Grid')
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)

        # Trying add a child without description
        for combo in grid_slave._widgets.values():
            # Position 0 (zero) is empty
            combo.select_item_by_position(1)
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), True)
        self.click(grid_slave.add_product_button)
        warning.assert_called_once_with(
            'You should fill the description first')

        # Filling the description and try again
        editor_step.slave.description.update('grid test')
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), True)
        self.click(grid_slave.add_product_button)
        # Testing the sensitivity right after adding a child
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)

        # One combo not filled with an valid option
        combo = grid_slave._widgets.values()[0]
        # Position 0 (zero) is empty
        combo.select_item_by_position(0)
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)

        # Trying add a child with exactly the same attribute_option
        for combo in grid_slave._widgets.values():
            combo.select_item_by_position(1)
        self.assertEquals(grid_slave.add_product_button.get_sensitive(), False)