Browse Source

Prevent a bad query where state is None. Make tests failures more clear. Clarify on-screen instructions for list mode.

master
poikilos 3 years ago
parent
commit
385549996b
  1. 33
      utilities/enissue.py

33
utilities/enissue.py

@ -30,6 +30,7 @@ import sys
import json import json
import os import os
import platform import platform
import copy
from datetime import datetime, timedelta from datetime import datetime, timedelta
python_mr = sys.version_info.major python_mr = sys.version_info.major
try: try:
@ -139,9 +140,17 @@ apis["Gitea"] = gitea_defaults
def tests(): def tests():
for name, options in apis.items(): for name, options in apis.items():
assert(options.get('default_query') is not None) if options.get('default_query') is None:
assert(isinstance(options.get('default_query'), dict)) raise AssertionError("There must be a 'default_query'"
assert(options['default_query'].get('state') is not None) " in apis['{}']."
"".format(name))
if not isinstance(options.get('default_query'), dict):
raise AssertionError(" apis['{}']['default_query']"
" must be a dict."
"".format(name))
for k,v in options['default_query']:
if v is None:
raise AssertionError("{} is None".format(k))
def debug(msg): def debug(msg):
@ -507,6 +516,10 @@ class Repo:
debug("get_issues...") debug("get_issues...")
debug(" options={}".format(options)) debug(" options={}".format(options))
debug(" query={}".format(query)) debug(" query={}".format(query))
if query is not None:
for k,v in query.items():
if v is None:
raise ValueError("{} is None.".format(k))
debug(" issue_no={}".format(issue_no)) debug(" issue_no={}".format(issue_no))
debug(" search_terms={}".format(search_terms)) debug(" search_terms={}".format(search_terms))
p = self.log_prefix p = self.log_prefix
@ -1398,10 +1411,14 @@ def main():
msg = None msg = None
if (mode != "issue"): if (mode != "issue"):
query = None query = None
if (state != repo.default_query.get('state')): if repo.default_query is not None:
query = { if (state != repo.default_query.get('state')):
'state': state if state is not None:
} query = {
'state': state
}
else:
query = copy.deepcopy(repo.default_query)
results, msg = repo.load_issues(options, query=query, results, msg = repo.load_issues(options, query=query,
search_terms=search_terms) search_terms=search_terms)
debug("* done load_issues for list") debug("* done load_issues for list")
@ -1566,7 +1583,7 @@ def main():
else: else:
print() print()
print() print()
print("To view details, type") print("To view details of one of these issues, type")
print(" ./" + me) print(" ./" + me)
print("followed by a number.") print("followed by a number.")
else: else:

Loading…
Cancel
Save