rhevm-qe-automation / pytest_jira

py.test plugin to integrate with JIRA
GNU General Public License v2.0
29 stars 25 forks source link

Fix potential AttributeError #81

Closed liiight closed 7 years ago

liiight commented 7 years ago
    def wrapper_jira_issue(issue_id):
>       jira_plugin = getattr(request.config, '_jira')
E       AttributeError: 'Config' object has no attribute '_jira'
liiight commented 7 years ago

On an unrelated note, I think the jira_issue fixture is reversed... Currently it return if the issue is resolved, maybe it should return the opposite, if it's open?

lukas-bednar commented 7 years ago

this PR looks good, can you please add these two tests, that we can catch such issue in future?

diff --git a/tests/test_jira.py b/tests/test_jira.py
index a5a087f..c508834 100644
--- a/tests/test_jira.py
+++ b/tests/test_jira.py
@@ -60,6 +60,17 @@ def assert_outcomes(
     assert outcomes.get("xfailed", 0) == xfailed

+def test_jira_plugin_disabled(testdir):
+    testdir.makepyfile("""
+        import pytest
+        @pytest.mark.jira("ORG-1382", run=True)
+        def test_pass():
+            assert True
+    """)
+    result = testdir.runpytest()
+    assert_outcomes(result, 1, 0, 0)
+
+
 def test_jira_marker_no_args(testdir):
     testdir.makeconftest(CONFTEST)
     testdir.makepyfile("""
@@ -706,6 +717,17 @@ def test_run_test_case_true1(testdir):
     assert_outcomes(result, passed=0, skipped=0, failed=0, error=0, xfailed=1)

+def test_jira_fixture_plugin_disabled(testdir):
+    testdir.makepyfile("""
+        import pytest
+
+        def test_pass(jira_issue):
+            assert jira_issue("ORG-1382") is None
+    """)
+    result = testdir.runpytest()
+    assert_outcomes(result, 1, 0, 0)
+
+
 def test_jira_fixture_run_positive(testdir):
     testdir.makeconftest(CONFTEST)
     testdir.makepyfile("""

regarding to your note, I think it is matter of documentation. you defined interface and described it in readme. so it is fine then.

But feel free to send other PR and we will see.

codecov-io commented 7 years ago

Codecov Report

Merging #81 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #81   +/-   ##
=======================================
  Coverage   98.34%   98.34%           
=======================================
  Files           1        1           
  Lines         181      181           
=======================================
  Hits          178      178           
  Misses          3        3
Impacted Files Coverage Δ
pytest_jira.py 98.34% <100%> (ø) :arrow_up:

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 e7d15eb...17108a9. Read the comment docs.

liiight commented 7 years ago

well, makes more sense to make that having jira_issue(issue_id) return True if its unresolved, as in it's still an issue. also i got another bugfix pending, need you to merge this first since i didn't branch before opening this one 🤕