redash/tests/tasks/test_refresh_schemas.py
Arik Fraimovich 2dff8b9a00
Black support for the Python codebase (#4297)
* Apply black formatting

* Add auto formatting when committing to master

* Update CONTRIBUTING.md re. Black & Prettier
2019-12-11 13:54:29 +02:00

32 lines
934 B
Python

from mock import patch
from tests import BaseTestCase
from redash.tasks import refresh_schemas
class TestRefreshSchemas(BaseTestCase):
def test_calls_refresh_of_all_data_sources(self):
self.factory.data_source # trigger creation
with patch(
"redash.tasks.queries.maintenance.refresh_schema.delay"
) as refresh_job:
refresh_schemas()
refresh_job.assert_called()
def test_skips_paused_data_sources(self):
self.factory.data_source.pause()
with patch(
"redash.tasks.queries.maintenance.refresh_schema.delay"
) as refresh_job:
refresh_schemas()
refresh_job.assert_not_called()
self.factory.data_source.resume()
with patch(
"redash.tasks.queries.maintenance.refresh_schema.delay"
) as refresh_job:
refresh_schemas()
refresh_job.assert_called()