Uploaded image for project: 'DC/OS'
  1. DC/OS
  2. DCOS_OSS-4742

Failed gen validate does not show reason for failure of assertions

    Details

    • Sprint:
      Security Sprint 38
    • Story Points:
      1

      Description

      Currently, if the validate_success or validate_error function fail during gen unittests the user does not get to know the full output of why an assertion failed.

      This can be fixed by utilizing a pytest functionality called assert rewriting.

      Before:

          def validate_error(new_arguments, key, message, unset=None):
              assert gen.validate(arguments=make_arguments(new_arguments)) == {
                  'status': 'errors',
                  'errors': {key: {'message': message}},
      >           'unset': set() if unset is None else unset,
              }
      E       AssertionError
      

      After:

          def validate_error(new_arguments, key, message, unset=None):
      >       assert gen.validate(arguments=make_arguments(new_arguments)) == {
                  'status': 'errors',
                  'errors': {key: {'message': message}},
                  'unset': set() if unset is None else unset,
              }
      E       AssertionError: assert {'errors': {'...unset': set()} == {'errors': {'r...unset': set()}
      E         Common items:
      E         {'status': 'errors', 'unset': set()}
      E         Differing items:
      E         {'errors': {'resolvers': {'message': 'Must be an integer but got a str: abc'}}} != {'errors': {'resolver': {'message': 'Must be an integer but got a str: abc'}}}
      E         Full diff:
      E         - {'errors': {'resolvers': {'message': 'Must be an integer but got a str: abc'}},
      E         ?                      -
      E         + {'errors': {'resolver': {'message': 'Must be an integer but got a str: abc'}},
      E         'status': 'errors',
      E         'unset': set()}
      

        Attachments

          Activity

            People

            • Assignee:
              timweidner Tim Weidner
              Reporter:
              timweidner Tim Weidner
              Team:
              Security Team
              Watchers:
              Mergebot, Tim Weidner
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: