Closed andrehenriquemendes closed 3 years ago
Hi. Could you maybe post a snippet of the testing code, so we can see when/how you're refreshing the materialized view?
Hi. Could you maybe post a snippet of the testing code, so we can see when/how you're refreshing the materialized view?
Hi, @mikicz! After create the original instance, it call refresh_materialized_view() to refresh
def refresh_discounts_materialized_view(self):
with connection.cursor() as cursor:
cursor.execute(f'REFRESH MATERIALIZED VIEW discount_checker_setup_view')
def test_list_discounts(self, mocked):
self.create_discount() # create original instance
self.refresh_discounts_materialized_view()
PS:
Have you tried refreshing with this instead of the cursor query?
DiscourdCheckerSetupView.refresh()
(assuming that's the class where you're defining the mat. view)
I tried too, it was my first attempt
Hm, that's strange them. It's hard for me to judge without seeing more of the code unfortunately. I use materialized views with pytest and they work fine, so not sure what's exactly going on.
Two things I'd investigate:
@mikicz, can you show me how is your model and migration? Just to compare with mine. I have been with this problem for days
I can't provide any actual examples from my codebase unfortunately. But setup-wise there's nothing special, a regular django model with standard migrations and a materialized view without any special stuff, like it's in the documentation: https://github.com/mikicz/django-pgviews#materialized-views
Hey guys,
I have a issue when test materialized views with pytest.
Basically, when I refresh the materialized views by endpoint works, but when I refresh with tests, don't works.
The refresh method works, but don't update datas on materialized view.
Thank you!