Made test parts that depends on yanglint conditional. Added some informational messages about tests skipped due to missing resources.

- Legacy-Id: 18255
This commit is contained in:
Henrik Levkowetz 2020-07-24 13:43:59 +00:00
parent e056abd888
commit f0baae3623
3 changed files with 15 additions and 9 deletions

View file

@ -238,7 +238,7 @@ class DraftYangChecker(object):
# yanglint
set_coverage_checking(False) # we can't count the following as it may or may not be run, depending on setup
if settings.SUBMIT_YANGLINT_COMMAND:
if settings.SUBMIT_YANGLINT_COMMAND and os.path.exists(settings.YANGLINT_BINARY):
cmd_template = settings.SUBMIT_YANGLINT_COMMAND
command = [ w for w in cmd_template.split() if not '=' in w ][0]
cmd_version = VersionInfo.objects.get(command=command).version

View file

@ -266,7 +266,7 @@ class SubmitTests(TestCase):
self.assertContains(r, 'xym')
self.assertContains(r, 'pyang')
if settings.SUBMIT_YANGLINT_COMMAND:
if settings.SUBMIT_YANGLINT_COMMAND and os.path.exists(settings.YANGLINT_BINARY):
self.assertContains(r, 'yanglint')
q = PyQuery(r.content)
@ -1249,11 +1249,11 @@ class SubmitTests(TestCase):
m = q('#yang-validation-message').text()
for command in ['xym', 'pyang', 'yanglint']:
version = VersionInfo.objects.get(command=command).version
if command != 'yanglint' or settings.SUBMIT_YANGLINT_COMMAND:
if command != 'yanglint' or (settings.SUBMIT_YANGLINT_COMMAND and os.path.exists(settings.YANGLINT_BINARY)):
self.assertIn(version, m)
self.assertIn("draft-yang-testing-invalid-00.txt", m)
self.assertIn("error: syntax error: illegal keyword: ;", m)
if settings.SUBMIT_YANGLINT_COMMAND:
if settings.SUBMIT_YANGLINT_COMMAND and os.path.exists(settings.YANGLINT_BINARY):
self.assertIn("No validation errors", m)

View file

@ -45,13 +45,19 @@ from ietf.utils.test_runner import get_template_paths, set_coverage_checking
from ietf.utils.test_utils import TestCase
skip_wiki_glue_testing = False
skip_message = ""
skip_message_svn = ""
skip_message_trac = ""
try:
import svn # pyflakes:ignore
except ImportError as e:
skip_wiki_glue_testing = True
skip_message = "Skipping trac tests: %s" % e
print(" "+skip_message)
skip_message_svn = "Skipping trac tests: %s" % e
print(" "+skip_message_svn)
if sys.version_info.major==3:
skip_version_trac = True
skip_message_trac = "Skipping trac tests: Trac not available for Python3 as of 14 Jul 2019, 04 Jul 2020"
print(" "+skip_message_trac)
class SendingMail(TestCase):
@ -282,8 +288,8 @@ class TemplateChecksTestCase(TestCase):
r = self.client.get(url)
self.assertTemplateUsed(r, '500.html')
@skipIf(sys.version_info.major==3, "Trac not available for Python3 as of 14 Jul 2019")
@skipIf(skip_wiki_glue_testing, skip_message)
@skipIf(skip_version_trac, skip_message_trac)
@skipIf(skip_wiki_glue_testing, skip_message_svn)
class TestWikiGlueManagementCommand(TestCase):
def setUp(self):