dpgaspar commented on PR #20892: URL: https://github.com/apache/superset/pull/20892#issuecomment-1239460250
> Hi @dpgaspar & @betodealmeida! I am tagging you on this comment as @michael-s-molina said you two were who I should go to with this question about Pytest. > > I am currently working on adding the new back-end code for tagging datasets, however, when it comes to the integration tests, I am running into a brick wall so to speak. I am trying to mock the `TAGGING_SYSTEM` feature flag in my tests, however, it does not seem to be working. When I manually go into the `superset > connectors > sqla > models.py` (Dataset) file around like 2542 where it checks if the flag is enabled, if I take that check out, the test passes. Same thing with all of the other objects I am testing (`superset > models ? core.py` (Saved Query - line 850), `superset > models > dashboard.py` (Dashboard - line 458), and `superset > models > slice.py` (Chart - line 371)). > > I have tried all sorts of different methods to mock the feature flag (as you can see by all the commits on this PR), but I have not been successful as of yet. > > Michael did mention this, but I am still not sure how to fix the tests: "I think using @with_feature_flags(TAGGING_SYSTEM=True) like the other tests would be sufficient. I think it’s failing because the events in models.py are being registered when the module is loaded, which happens before the tests’ decorators/mocks. At that time, the flag is false" > > Would you be able to take a look at this PR and see if you can help me with mocking the feature flag in these integration tests? I think @michael-s-molina is right. Feature flags evaluation should not happen at module load time, try moving those conditional sqlalchemy event listeners to https://github.com/apache/superset/blob/c4b6fc5a6a93b5912bef863d7279a213599cda2f/superset/initialization/__init__.py#L583 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
