def test_should_return_false_on_empty_list(self, mock_hook): task = GCSObjectsWtihPrefixExistenceSensor( task_id="task-id", bucket=TEST_BUCKET, prefix=TEST_PREFIX, google_cloud_conn_id=TEST_GCP_CONN_ID, delegate_to=TEST_DELEGATE_TO, ) mock_hook.return_value.list.return_value = [] result = task.poke(mock.MagicMock) self.assertEqual(False, result)
def test_should_pass_arguments_to_hook(self, mock_hook): task = GCSObjectsWtihPrefixExistenceSensor( task_id="task-id", bucket=TEST_BUCKET, prefix=TEST_PREFIX, google_cloud_conn_id=TEST_GCP_CONN_ID, delegate_to=TEST_DELEGATE_TO, ) mock_hook.return_value.list.return_value = ["NOT_EMPTY_LIST"] result = task.poke(mock.MagicMock) mock_hook.assert_called_once_with( delegate_to=TEST_DELEGATE_TO, google_cloud_storage_conn_id=TEST_GCP_CONN_ID ) mock_hook.return_value.list.assert_called_once_with(TEST_BUCKET, prefix=TEST_PREFIX) self.assertEqual(True, result)
def test_should_pass_arguments_to_hook(self, mock_hook): task = GCSObjectsWtihPrefixExistenceSensor( task_id="task-id", bucket=TEST_BUCKET, prefix=TEST_PREFIX, google_cloud_conn_id=TEST_GCP_CONN_ID, delegate_to=TEST_DELEGATE_TO, impersonation_chain=TEST_IMPERSONATION_CHAIN, ) mock_hook.return_value.list.return_value = ["NOT_EMPTY_LIST"] result = task.poke(mock.MagicMock) mock_hook.assert_called_once_with( delegate_to=TEST_DELEGATE_TO, gcp_conn_id=TEST_GCP_CONN_ID, impersonation_chain=TEST_IMPERSONATION_CHAIN, ) mock_hook.return_value.list.assert_called_once_with(TEST_BUCKET, prefix=TEST_PREFIX) assert result is True