def test_show(self, yesno):
        device = self.create_card_device(u'Cielo')
        self.create_card_device(u'Santander')

        slave = CardDeviceListSlave(store=self.store)
        slave.set_reuse_store(self.store)
        self.check_slave(slave, 'slave-carddevicelist-show')

        slave.listcontainer.list.select(device)

        yesno.return_value = True
        self.click(slave.listcontainer.remove_button)
        yesno.assert_called_once_with(
            'Removing this device will also remove'
            ' all related costs.', gtk.RESPONSE_NO, "Remove", "Keep device")
    def testShow(self, yesno):
        device = self.create_card_device(u'Cielo')
        self.create_card_device(u'Santander')

        slave = CardDeviceListSlave(store=self.store)
        slave.set_reuse_store(self.store)
        self.check_slave(slave, 'slave-carddevicelist-show')

        slave.listcontainer.list.select(device)

        yesno.return_value = True
        self.click(slave.listcontainer.remove_button)
        yesno.assert_called_once_with('Removing this device will also remove'
                                      ' all related costs.', gtk.RESPONSE_NO,
                                      "Remove",
                                      "Keep device")
    def test_remove(self, info, yesno):
        device = self.create_card_device(u'Default Device')
        devices = self.store.find(CardPaymentDevice, description=u'Default Device').count()
        self.assertEquals(devices, 1)

        slave = CardDeviceListSlave(store=self.store, reuse_store=True)
        slave.listcontainer.list.select(device)
        yesno.return_value = True

        self.create_operation_cost(device=device)
        provider = self.create_credit_provider(u"Provider")
        provider.provider_id = u"PROVIDER TEST"
        provider.default_device = device
        self.create_credit_card_data(device=device, provider=provider)

        self.click(slave.listcontainer.remove_button)
        providers = self.store.find(CreditProvider, default_device=device).count()
        info.assert_called_with("Can not remove this device.\n"
                                "It is being used as default device in %s credit provider(s)."
                                % providers)

        provider.default_device = None
        self.click(slave.listcontainer.remove_button)
        yesno.assert_called_once_with("Removing this device will also remove"
                                      " all related costs.", gtk.RESPONSE_NO,
                                      "Remove",
                                      "Keep device")

        # Check if device and its references were deleted
        devices = self.store.find(CardPaymentDevice, description=u'Default Device').count()
        operations = self.store.find(CardOperationCost, device=device).count()
        card_data = self.store.find(CreditCardData, device=device).count()
        self.assertEquals(devices, 0)
        self.assertEquals(operations, 0)
        self.assertEquals(card_data, 0)
Example #4
0
    def test_show(self):
        self.create_card_device(u'Cielo')
        self.create_card_device(u'Santander')

        slave = CardDeviceListSlave(store=self.store, reuse_store=True)
        self.check_slave(slave, 'slave-carddevicelist-show')