Skip to content

Commit

Permalink
Merge pull request #516 from geoadmin/feat-PB-1279-fix-text
Browse files Browse the repository at this point in the history
PB-1279: Fix test
  • Loading branch information
msom authored Feb 12, 2025
2 parents 088ad5e + f02702b commit 79f2589
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions app/tests/tests_10/test_items_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,12 @@ def test_item_atomic_upsert_update_500(self):


@override_settings(FEATURE_AUTH_ENABLE_APIGW=True)
class ItemsBulkCreateEndpointTestCase(StacBaseTestCase):
class ItemsBulkCreateEndpointTestCase(StacBaseTransactionTestCase):

@classmethod
def setUpTestData(cls):
cls.factory = Factory()
cls.collection = cls.factory.create_collection_sample(db_create=True)
cls.payload = {
def setUp(self):
self.factory = Factory()
self.collection = self.factory.create_collection_sample(db_create=True)
self.payload = {
"features": [
{
"id": "item-1",
Expand Down Expand Up @@ -873,8 +872,6 @@ def setUpTestData(cls):
},
]
}

def setUp(self):
self.client = Client(headers=get_auth_headers())

def test_items_endpoint_post_creates_given_items_as_expected(self):
Expand Down Expand Up @@ -953,17 +950,6 @@ def test_items_endpoint_post_returns_400_if_item_exists_already(self):
collection_name = self.collection["name"]
self.factory.create_item_sample(self.collection.model, sample='item-1', db_create=True)

# Perform a meaningless GET request in order to have a session from authentication.
#
# If we don't do this, the authentication middleware catches the HTTP 400
# error while trying to set up a session. The session initialization then
# fails with a HTML error message (not a JSON) complaining that
#
# "The request's session was deleted before the request completed.".
#
# This is a workaround that we might be able to replace with a more proper solution.
self.client.get(path=f'/{STAC_BASE_V}/collections/{collection_name}/items')

response = self.client.post(
path=f'/{STAC_BASE_V}/collections/{collection_name}/items',
data=self.payload,
Expand Down

0 comments on commit 79f2589

Please sign in to comment.