I’m facing an issue while testing to update a collection. Below is my code:
@pytest.fixture
def update_collection(api_client):
def do_update_collection(collection):
return api_client.put(f'/store/collections/{collection.id}/', collection)
return do_update_collection
@pytest.mark.django_db
class TestUpdateCollection:
def test_if_user_is_anonymous_returns_401(self, update_collection):
collection = baker.make(Collection)
collection.title = 'new_title'
response = update_collection(collection)
assert response.status_code == status.HTTP_401_UNAUTHORIZED
But I’m getting the following error while running the test:
E AttributeError: ‘Collection’ object has no attribute ‘items’
Why does it expect the collection object to contain ‘items’?
Thanks in advance for your help!