NASA-IMPACT / veda-backend

Backend services for VEDA
Other
13 stars 5 forks source link

test: Fix transaction unit tests #425

Closed stephenkilbourn closed 2 months ago

stephenkilbourn commented 2 months ago

I've added a small change in the stac_api/runtime/tests/conftest.py. This gives a similar error on each of the attempts to POST: The error error:

>       response = self.api_client.post(
            collections_endpoint, json=self.invalid_stac_collection
        )
E       AttributeError: 'async_generator' object has no attribute 'post'

stac_api/runtime/tests/test_transactions.py:63: AttributeError

this got past the starlette error that we were seeing in develop:

self = <starlette.datastructures.State object at 0x10bf0b1f0>, key = 'get_connection'

    def __getattr__(self, key: typing.Any) -> typing.Any:
        try:
            return self._state[key]
        except KeyError:
            message = "'{}' object has no attribute '{}'"
>           raise AttributeError(message.format(self.__class__.__name__, key))
E           AttributeError: 'State' object has no attribute 'get_connection'

I'm at a loss on how to get past the new post error, though.

stephenkilbourn

smohiudd commented 2 months ago

@vincentsarago are you able to help us with this PR? I think it's stumped all of Data Services so far 😬

We're mainly seeing a get_connection error when trying POST using the transactions endpoints in stacfastapi-pgstac.

../../../../../.pyenv/versions/veda-backend/lib/python3.11/site-packages/stac_fastapi/pgstac/transactions.py:93: in create_item
    async with request.app.state.get_connection(request, "w") as conn:

Maybe it has something to do with how we're importing the app in our tests.

smohiudd commented 2 months ago

I deployed this to https://8ajdmuk7ld.execute-api.us-west-2.amazonaws.com/docs and tested the CREATE, PUT and POST transaction endpoints, and the validation is working.