-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1773 from getredash/patches
Split refresh schemas into separate tasks and add a timeout.
- Loading branch information
Showing
3 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import datetime | ||
from mock import patch, call, ANY | ||
|
||
from mock import ANY, call, 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.models.DataSource.get_schema') as get_schema: | ||
with patch('redash.tasks.queries.refresh_schema.apply_async') as refresh_job: | ||
refresh_schemas() | ||
get_schema.assert_called_with(refresh=True) | ||
refresh_job.assert_called() | ||
|
||
def test_skips_paused_data_sources(self): | ||
self.factory.data_source.pause() | ||
|
||
with patch('redash.models.DataSource.get_schema') as get_schema: | ||
with patch('redash.tasks.queries.refresh_schema.apply_async') as refresh_job: | ||
refresh_schemas() | ||
get_schema.assert_not_called() | ||
refresh_job.assert_not_called() | ||
|
||
self.factory.data_source.resume() | ||
|
||
with patch('redash.models.DataSource.get_schema') as get_schema: | ||
with patch('redash.tasks.queries.refresh_schema.apply_async') as refresh_job: | ||
refresh_schemas() | ||
get_schema.assert_called_with(refresh=True) | ||
refresh_job.assert_called() |