Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade extension to CKAN 2.11 #9

Merged
merged 21 commits into from
Jan 7, 2025
Merged

Upgrade extension to CKAN 2.11 #9

merged 21 commits into from
Jan 7, 2025

Conversation

avdata99
Copy link
Member

@avdata99 avdata99 commented Jan 3, 2025

No description provided.

@avdata99 avdata99 requested review from pdelboca and germankay January 3, 2025 17:46
Comment on lines 27 to 30
@pytest.fixture
def announcement_migrate():

_apply_alembic_migrations()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avdata99 I'm not exactly sure what's going on here. Is the migrate_db_for fixture broken in CKAN 2.11?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't manage to find the problem @pdelboca
I added the with_plugins fixture and now it's fixed

Copy link
Member

@pdelboca pdelboca Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avdata99 I suggest to change this fixture for the following one:

import pytest


@pytest.fixture
def clean_db(reset_db, migrate_db_for):
    reset_db()
    migrate_db_for("announcements")

The with_plugins is necessary to force test to use the ckan.plugins definition of the test.ini file. Without the fixture, it will be ignored.

Unit testing with CKAN is in my opinion confusing. There is a whole discussion about it, while it didn't got anywhere I think it documents what's going on when testing CKAN. I will definitely recommend making a 🧉 and read it.

Copy link
Member

@pdelboca pdelboca Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avdata99 I have been debugging and there is a nasty bug going around.

I was able to narrow it to the with_request_context fixture that it is cleaning the current_user object for some reason. If you remove the with_request_context fixture the index view will have a proper user logged in.

Note: The Flask's TestClient should create the request context when executing app.get() so I don't see the need of having it. Usually with_request_context is used when we want to test actions that expects a request without using the TestClient, but instead of relying on Flask's api we have this extra custom fixture.

@avdata99 avdata99 requested a review from pdelboca January 7, 2025 17:03
@avdata99
Copy link
Member Author

avdata99 commented Jan 7, 2025

Done with the proposed changed. Looks good now.
Merge to continue but open to apply more changes @pdelboca

@avdata99 avdata99 merged commit a32ce01 into main Jan 7, 2025
3 checks passed
@avdata99 avdata99 deleted the ckan-2.11 branch January 7, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants