Commits

Tetsuya Morimoto  committed 239e6b0

fixed to show apropriate message when the ticket id in relation field is itself
added pep8 test script

  • Participants
  • Parent commits 0efd427

Comments (0)

Files changed (3)

File ticketref/api.py

 
     def validate_ticket(self, req, ticket):
         if self.has_ticket_refs(ticket):
+            _prop = ("ticket-custom", "ticketref.label")
             for _id in ticket[TICKETREF].split(","):
                 ref_id = int(_id.strip())
                 try:
                     assert ref_id != ticket.id
                     Ticket(self.env, ref_id)
+                except AssertionError:
+                    msg = "Ticket %s is this ticket id, remove it." % ref_id
+                    yield self.env.config.get(*_prop), msg
                 except Exception, err:
-                    _prop = ("ticket-custom", "ticketref.label")
                     yield self.env.config.get(*_prop), err

File ticketref/tests/test_pep8.py

+# -*- coding: utf-8 -*-
+
+from os.path import (abspath, dirname, isdir)
+import pep8
+
+CURRENT_DIR = dirname(abspath(__file__))
+BASE_DIR = dirname(CURRENT_DIR)
+
+
+def test_pep8():
+    arglist = [
+        "--statistics",
+        "--filename=*.py",
+        "--show-source",
+        "--repeat",
+        "--ignore=E301,E302,E701",
+        #"--show-pep8",
+        #"-qq",
+        #"-v",
+        BASE_DIR,
+    ]
+
+    options, args = pep8.process_options(arglist)
+    runner = pep8.input_file
+
+    for path in args:
+        if isdir(path):
+            pep8.input_dir(path, runner=runner)
+        elif not pep8.excluded(path):
+            options.counters["files"] += 1
+            runner(path)
+
+    pep8.print_statistics()
+    errors = pep8.get_count("E")
+    warnings = pep8.get_count("W")
+    message = "pep8: %d errors / %d warnings" % (errors, warnings)
+    print message
+    assert errors + warnings == 0, message

File ticketref/web_ui.py

 
 COPY_TICKET_FIELDS = [
     "type", "priority", "milestone", "component", "version", "keywords",
-    "owner", 
+    "owner",
 ]