Skip to content

[AIRFLOW-5732] Add unit test for the version command#6401

Merged
feng-tao merged 1 commit into
apache:masterfrom
sekikn:AIRFLOW-5732
Oct 24, 2019
Merged

[AIRFLOW-5732] Add unit test for the version command#6401
feng-tao merged 1 commit into
apache:masterfrom
sekikn:AIRFLOW-5732

Conversation

@sekikn
Copy link
Copy Markdown
Contributor

@sekikn sekikn commented Oct 24, 2019

Make sure you have checked all steps below.

Jira

  • My PR addresses the following Airflow Jira issues and references them in the PR title. For example, "[AIRFLOW-XXX] My Airflow PR"
    • https://issues.apache.org/jira/browse/AIRFLOW-5732
    • In case you are fixing a typo in the documentation you can prepend your commit with [AIRFLOW-XXX], code changes always need a Jira issue.
    • In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal (AIP).
    • In case you are adding a dependency, check if the license complies with the ASF 3rd Party License Policy.

Description

  • Here are some details about my PR, including screenshots of any UI changes:

This PR adds a unit test for the airflow version command.

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

test_cli_version in tests/core.py

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
    • If you implement backwards incompatible changes, please leave a note in the Updating.md so we can assign it to a appropriate release

There's no unit test for the `airflow version` command for now. This PR
adds a unit test for that command so as to avoid an accidental
regression.
@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 24, 2019

Codecov Report

Merging #6401 into master will decrease coverage by 0.3%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6401      +/-   ##
==========================================
- Coverage   80.61%   80.31%   -0.31%     
==========================================
  Files         626      626              
  Lines       36217    36217              
==========================================
- Hits        29196    29086     -110     
- Misses       7021     7131     +110
Impacted Files Coverage Δ
airflow/kubernetes/volume_mount.py 44.44% <0%> (-55.56%) ⬇️
airflow/kubernetes/volume.py 52.94% <0%> (-47.06%) ⬇️
airflow/kubernetes/pod_launcher.py 45.25% <0%> (-46.72%) ⬇️
airflow/kubernetes/kube_client.py 33.33% <0%> (-41.67%) ⬇️
...rflow/contrib/operators/kubernetes_pod_operator.py 70.14% <0%> (-28.36%) ⬇️
airflow/bin/cli.py 66.31% <0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3c3812...9ff0c4f. Read the comment docs.

@feng-tao feng-tao merged commit 47eac79 into apache:master Oct 24, 2019
Comment thread tests/core.py
os.remove('variables2.json')
os.remove('variables3.json')

def test_cli_version(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this test is in the wrong place. tests/cli/test_cli.py is a better file.

I am also afraid of sys.stdout mocking. Python has a special mechanism for this. 
https://github.com/sekikn/incubator-airflow/blob/9ff0c4f79a009618215a2af60418f664168456f4/tests/cli/test_cli.py#L344-L352

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment @mik-laj!

I'm afraid this test is in the wrong place. tests/cli/test_cli.py is a better file.

The reason that I added the new test to test/core.py was it has many cli-related tests in its TestCli class. I have no objection to move the new test into tests/cli/test_cli.py, but is there any criteria to put a new cli-related test into it (or should we basically use tests/cli/test_cli.py in the future)?

I am also afraid of sys.stdout mocking. Python has a special mechanism for this.

I didn't use contextlib.redirect_stdout because of concern for the compatibility with Python2, but I've just noticed we're going to drop it on the master branch. I'll address it on another PR, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants