def test_is_not_emitted_when_sumitting_to_mws_fails(self):
        self.signal_sent = False
        fulfillment_order_mock = mock.Mock()
        fulfillment_order_mock.get_order_kwargs = mock.Mock(return_value={})

        def fake_receiver(fulfillment_order, **kwargs):
            self.signal_sent = True
            self.assertEquals(fulfillment_order, fulfillment_order_mock)

        mws_fulfillment_created.connect(fake_receiver)

        with mock.patch('oscar_mws.fulfillment.gateway.get_merchant_connection') as gmc_mock:  # noqa
            create_fulfillment_order = mock.MagicMock(side_effect=MWSError())
            gmc_mock.return_value = mock.Mock(
                create_fulfillment_order=create_fulfillment_order)

            submit_fulfillment_order(fulfillment_order_mock)

        if self.signal_sent:
            self.fail("no signal should have been sent but was.")
示例#2
0
    def test_is_not_emitted_when_sumitting_to_mws_fails(self):
        self.signal_sent = False
        fulfillment_order_mock = mock.Mock()
        fulfillment_order_mock.get_order_kwargs = mock.Mock(return_value={})

        def fake_receiver(fulfillment_order, **kwargs):
            self.signal_sent = True
            self.assertEquals(fulfillment_order, fulfillment_order_mock)

        mws_fulfillment_created.connect(fake_receiver)

        with mock.patch('oscar_mws.fulfillment.gateway.get_merchant_connection'
                        ) as gmc_mock:  # noqa
            create_fulfillment_order = mock.MagicMock(side_effect=MWSError())
            gmc_mock.return_value = mock.Mock(
                create_fulfillment_order=create_fulfillment_order)

            submit_fulfillment_order(fulfillment_order_mock)

        if self.signal_sent:
            self.fail("no signal should have been sent but was.")
示例#3
0
    def test_is_emitted_when_successfully_submitted_to_mws(self):
        self.signal_sent = False
        fulfillment_order_mock = mock.Mock()
        fulfillment_order_mock.get_order_kwargs = mock.Mock(return_value={})

        def fake_receiver(fulfillment_order, **kwargs):
            self.signal_sent = True
            self.assertEquals(fulfillment_order, fulfillment_order_mock)

        mws_fulfillment_created.connect(fake_receiver)

        with mock.patch('oscar_mws.fulfillment.gateway.get_merchant_connection') as gmc_mock:
            connection_mock = mock.Mock()
            gmc_mock.return_value = connection_mock
            outbound_mock = mock.Mock()
            connection_mock.outbound = outbound_mock
            connection_mock.create_fulfillment_order = mock.Mock(
                return_value=None)

            submit_fulfillment_order(fulfillment_order_mock)

        if not self.signal_sent:
            self.fail("MWS order signal not sent")
示例#4
0
    def test_is_emitted_when_successfully_submitted_to_mws(self):
        self.signal_sent = False
        fulfillment_order_mock = mock.Mock()
        fulfillment_order_mock.get_order_kwargs = mock.Mock(return_value={})

        def fake_receiver(fulfillment_order, **kwargs):
            self.signal_sent = True
            self.assertEquals(fulfillment_order, fulfillment_order_mock)

        mws_fulfillment_created.connect(fake_receiver)

        with mock.patch('oscar_mws.fulfillment.gateway.get_merchant_connection'
                        ) as gmc_mock:
            connection_mock = mock.Mock()
            gmc_mock.return_value = connection_mock
            outbound_mock = mock.Mock()
            connection_mock.outbound = outbound_mock
            connection_mock.create_fulfillment_order = mock.Mock(
                return_value=None)

            submit_fulfillment_order(fulfillment_order_mock)

        if not self.signal_sent:
            self.fail("MWS order signal not sent")