Repository: incubator-beam Updated Branches: refs/heads/python-sdk b2728cf13 -> 5f9851a83
Fix Incorrect State Usage in PipelineVerifier Unit Test Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/82fc5e40 Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/82fc5e40 Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/82fc5e40 Branch: refs/heads/python-sdk Commit: 82fc5e408f5c24f882036990e7d28bbbd1f08308 Parents: b2728cf Author: Mark Liu <[email protected]> Authored: Tue Dec 27 15:19:27 2016 -0800 Committer: Mark Liu <[email protected]> Committed: Tue Dec 27 15:19:27 2016 -0800 ---------------------------------------------------------------------- .../tests/pipeline_verifiers_test.py | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/82fc5e40/sdks/python/apache_beam/tests/pipeline_verifiers_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/tests/pipeline_verifiers_test.py b/sdks/python/apache_beam/tests/pipeline_verifiers_test.py index e32f603..9f70b45 100644 --- a/sdks/python/apache_beam/tests/pipeline_verifiers_test.py +++ b/sdks/python/apache_beam/tests/pipeline_verifiers_test.py @@ -20,7 +20,6 @@ import logging import unittest -from apache_beam.internal.clients import dataflow from apache_beam.runners.runner import PipelineState from apache_beam.runners.runner import PipelineResult from apache_beam.tests.pipeline_verifiers import PipelineStateMatcher @@ -29,20 +28,27 @@ from hamcrest import assert_that as hc_assert_that class PipelineVerifiersTest(unittest.TestCase): - def test_dataflow_job_state_matcher_success(self): - """Test DataflowJobStateMatcher successes when job finished in DONE""" + def test_pipeline_state_matcher_success(self): + """Test PipelineStateMatcher successes when using default expected state + and job actually finished in DONE + """ pipeline_result = PipelineResult(PipelineState.DONE) hc_assert_that(pipeline_result, PipelineStateMatcher()) + def test_pipeline_state_matcher_given_state(self): + """Test PipelineStateMatcher successes when matches given state""" + pipeline_result = PipelineResult(PipelineState.FAILED) + hc_assert_that(pipeline_result, PipelineStateMatcher(PipelineState.FAILED)) + def test_pipeline_state_matcher_fails(self): - """Test DataflowJobStateMatcher fails when job finished in - FAILED/CANCELLED/STOPPED/UNKNOWN/DRAINED""" - job_enum = dataflow.Job.CurrentStateValueValuesEnum - failed_state = [job_enum.JOB_STATE_FAILED, - job_enum.JOB_STATE_CANCELLED, - job_enum.JOB_STATE_STOPPED, - job_enum.JOB_STATE_UNKNOWN, - job_enum.JOB_STATE_DRAINED] + """Test PipelineStateMatcher fails when using default expected state + and job actually finished in CANCELLED/DRAINED/FAILED/STOPPED/UNKNOWN + """ + failed_state = [PipelineState.CANCELLED, + PipelineState.DRAINED, + PipelineState.FAILED, + PipelineState.STOPPED, + PipelineState.UNKNOWN] for state in failed_state: pipeline_result = PipelineResult(state)
