"""Tests for the project-specific CLI interface for the Garcon.""" from unittest.mock import MagicMock from snowflake_etl import cli def test_wait_until_complete(monkeypatch): """Test if exec is waiting if nonconcurrent workflow is running.""" b_mock = MagicMock() b_mock.client.return_value.count_open_workflow_executions.side_effect = [{ 'count': 1}, {'count': 1}, {'count': 0}] sleep_mock = MagicMock() monkeypatch.setattr(cli, 'boto3', b_mock) monkeypatch.setattr(cli, 'time', sleep_mock) cli.check_and_wait_until_complete( 'test_domain', 'production.fact_analytics-sync_incremental-into-prod.facts-' '2017-11-06T01_00_22-2017-11-06T12_27_34') assert len(sleep_mock.method_calls) == 2 assert ( b_mock.client.return_value.count_open_workflow_executions. call_count == 3) def test_run_activity_worker(mocker): """Test running of the worker.""" worker = mocker.patch('garcon.activity.ActivityWorker') cli.garcon('worker', 'sql2sf') assert worker.called