and the error i get is: ```self = '<http://localho...
# pact-python
j
and the error i get is:
Copy code
self = '<http://localhost:1234>'

    def cancel(self):
>       if self.status == 'progress':
E       AttributeError: 'str' object has no attribute 'status'

../orders_service/orders.py:48: AttributeError
🙌 1
m
so for that one, you're setting
self.__status
in init rather than
self.status
that's being used here - you'll need the attributes to match, so should be
self.__status
here as well
j
Thanks for pointing that out Mike. I updated that but i still get the same error. Do I need to do anything additional like pass in an object into the OrderClass or something? In this :
Copy code
with pact:
            response = consumer.cancel()
or something?
any ideas why I would be getting an error like this:
Copy code
ERROR consumer.py::test_cancel_scheduled_order - requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=3001): Max retries exceeded w...
oh i fixed hte above issue
I get this error now:
Copy code
pact = <pact.pact.Pact object at 0x103b5d3d0>, consumer = None

    def test_cancel_scheduled_order(pact, consumer):
            expected = \
           {
              "id": "1e54e244-d0ab-46ed-a88a-b9e6037655ef",
              "order": [
                {
                  "product": "coffee",
                  "quantity": 1,
                  "size": "small"
                }
              ],
              "scheduled": "Wed, 22 Jun 2022 09:21:26 GMT",
              "status": "cancelled"
            }
    
    
            (pact
            .given('A scheduled order exists and it is not cancelled already')
            .upon_receiving('a request for cancellation')
            .with_request('get', f'<http://localhost:3001/kitchen/schedule/{Like(12343)}/cancel>')
            .will_respond_with(200, body=Like(expected)))
    
            with pact:
                order = [{"id":1, "product":"coffee", "size":"small", "quantity":1}]
                payload = Order(id="76ac3eb5-a656-49e3-b973-17e7c992cc5e", created="2022-06-23T03:11:19.415574", items=order, status="created")
                # return Order.cancel(payload)
                # payload = Order(UUID, datetime.now, {"product":"coffee", "size":"large", "quantity":1}, "progress")
                print(payload)
>               response = consumer.cancel(payload)
E               AttributeError: 'NoneType' object has no attribute 'cancel'

consumer.py:110: AttributeError
hmmm im not sure what im doijng wrong can someone help?
m
At the top you have
consumer = None
that's why it doesn't have an attribute cancel, or any attributes
Or is that not a line of code as you have pact = an object above?
I would suggest spending some time learning about python in general, and testing in python, fixtures if you are using pytest.. and so on
j
I managed to resolve that issue
as to python yes im not really an expert on that.
Mike, I'm actually under considerable pressure to get contract testing done so unfortunately i don't have a lot of time to learn python properly. I just need to get to the state of getting contract testing working and demonstratable. So any help you can offer is greatly appreciated