Esempio n. 1
0
    def test_remove_with_product(self, warning):
        category = ClientCategory(name=u'foo', store=self.store)
        ClientCategoryPrice(category=category,
                            sellable=self.create_sellable(),
                            store=self.store)
        dialog = ClientCategoryDialog(self.store, reuse_store=True)
        dialog.list_slave.listcontainer.list.select(category)

        with mock.patch.object(dialog.list_slave.listcontainer,
                               'default_remove') as default_remove:
            default_remove.return_value = True
            self.click(dialog.list_slave.listcontainer.remove_button)
            msg = _("%s cannot be deleted, because is used in one or more "
                    "products.") % category.name
            warning.assert_called_once_with(msg)
Esempio n. 2
0
    def test_remove(self, run_dialog):
        category = ClientCategory(name=u'foo', store=self.store)
        client = self.create_client()
        client.category = category

        total_categoryes = self.store.find(ClientCategory).count()
        self.assertEqual(total_categoryes, 1)

        dialog = ClientCategoryDialog(self.store, reuse_store=True)
        dialog.list_slave.listcontainer.list.select(category)

        with mock.patch.object(dialog.list_slave.listcontainer,
                               'default_remove') as default_remove:
            default_remove.return_value = True
            self.click(dialog.list_slave.listcontainer.remove_button)

        total_categoryes = self.store.find(ClientCategory).count()
        self.assertEqual(total_categoryes, 0)
        self.assertEqual(client.category, None)
Esempio n. 3
0
 def test_add(self, run_dialog):
     dialog = ClientCategoryDialog(self.store)
     # user canceled the dialog
     run_dialog.return_value = None
     self.click(dialog.list_slave.listcontainer.add_button)
     self.assertEqual(run_dialog.call_count, 1)
Esempio n. 4
0
 def test_show(self):
     dialog = ClientCategoryDialog(self.store)
     self.check_dialog(dialog, 'dialog-clientcategory-show')