Only run yanglint and yanglint tests if we have it configured.
- Legacy-Id: 13636
This commit is contained in:
parent
25dfb0952d
commit
98dc0d0092
|
@ -212,24 +212,25 @@ class DraftYangChecker(object):
|
|||
message += "%s: %s:\n%s\n" % (cmd_version, cmd_template, out+"No validation errors\n" if code == 0 else err)
|
||||
|
||||
# yanglint
|
||||
cmd_template = settings.SUBMIT_YANGLINT_COMMAND
|
||||
command = cmd_template.split()[0]
|
||||
cmd_version = VersionInfo.objects.get(command=command).version
|
||||
cmd = cmd_template.format(model=path, rfclib=settings.SUBMIT_YANG_RFC_MODEL_DIR, draftlib=settings.SUBMIT_YANG_DRAFT_MODEL_DIR)
|
||||
code, out, err = pipe(cmd)
|
||||
if code > 0:
|
||||
error_lines = err.splitlines()
|
||||
for line in error_lines:
|
||||
if line.strip():
|
||||
try:
|
||||
if 'err : ' in line:
|
||||
errors += 1
|
||||
if 'warn: ' in line:
|
||||
warnings += 1
|
||||
except ValueError:
|
||||
pass
|
||||
#passed = passed and code == 0 # For the submission tool. Yang checks always pass
|
||||
message += "%s: %s:\n%s\n" % (cmd_version, cmd_template, out+"No validation errors\n" if code == 0 else err)
|
||||
if settings.SUBMIT_YANGLINT_COMMAND:
|
||||
cmd_template = settings.SUBMIT_YANGLINT_COMMAND
|
||||
command = cmd_template.split()[0]
|
||||
cmd_version = VersionInfo.objects.get(command=command).version
|
||||
cmd = cmd_template.format(model=path, rfclib=settings.SUBMIT_YANG_RFC_MODEL_DIR, draftlib=settings.SUBMIT_YANG_DRAFT_MODEL_DIR)
|
||||
code, out, err = pipe(cmd)
|
||||
if code > 0:
|
||||
error_lines = err.splitlines()
|
||||
for line in error_lines:
|
||||
if line.strip():
|
||||
try:
|
||||
if 'err : ' in line:
|
||||
errors += 1
|
||||
if 'warn: ' in line:
|
||||
warnings += 1
|
||||
except ValueError:
|
||||
pass
|
||||
#passed = passed and code == 0 # For the submission tool. Yang checks always pass
|
||||
message += "%s: %s:\n%s\n" % (cmd_version, cmd_template, out+"No validation errors\n" if code == 0 else err)
|
||||
|
||||
if errors==0 and warnings==0:
|
||||
dest = os.path.join(settings.SUBMIT_YANG_DRAFT_MODEL_DIR, model)
|
||||
|
|
|
@ -224,7 +224,8 @@ class SubmitTests(TestCase):
|
|||
|
||||
self.assertContains(r, 'xym')
|
||||
self.assertContains(r, 'pyang')
|
||||
self.assertContains(r, 'yanglint')
|
||||
if settings.SUBMIT_YANGLINT_COMMAND:
|
||||
self.assertContains(r, 'yanglint')
|
||||
|
||||
q = PyQuery(r.content)
|
||||
approve_button = q('[type=submit]:contains("Approve")')
|
||||
|
@ -985,10 +986,12 @@ class SubmitTests(TestCase):
|
|||
m = q('#yang-validation-message').text()
|
||||
for command in ['xym', 'pyang', 'yanglint']:
|
||||
version = VersionInfo.objects.get(command=command).version
|
||||
self.assertIn(version, m)
|
||||
if command != 'yanglint' or settings.SUBMIT_YANGLINT_COMMAND:
|
||||
self.assertIn(version, m)
|
||||
self.assertIn("draft-yang-testing-invalid-00.txt", m)
|
||||
self.assertIn("error: syntax error: illegal keyword: ;", m)
|
||||
self.assertIn("No validation errors", m)
|
||||
if settings.SUBMIT_YANGLINT_COMMAND:
|
||||
self.assertIn("No validation errors", m)
|
||||
|
||||
|
||||
class ApprovalsTestCase(TestCase):
|
||||
|
|
Loading…
Reference in a new issue