svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 326 forks source link

Architectural changes in v1.8 #163

Open svanoort opened 8 years ago

svanoort commented 8 years ago

Rollup of the top-level architecture changes in v1.8

Batch A: Internals

  1. Move execution logic into the test/benchmark object and out of the resttest.py class - they provide an execute method, and work on callbacks to log/return results (greatly simplifies all the below, quickly).
    • Signature: execute_macro(self, context=None, testConfig=None, cmdlineArgs=None, callbacks=DefaultLogging, _args, *_kwargs)
      • Lets you later first look for variables in self, then testConfig, then cmdlineArgs (which are a dictionary).
      • With this, we can remove the default value setting for testConfigs
      • Parsers (post-refactoring) can determine which elements are allowed for each item.
    • Allows for xUnit output: https://github.com/svanoort/pyresttest/issues/43
    • Allows for the macro steps to optimize dynamic evaluation, per https://github.com/svanoort/pyresttest/issues/101
    • Pre-work for dynamic macros/subcomponents, from https://github.com/svanoort/pyresttest/issues/92
    • Challenge: lots of command-line & test-set config options need to be consumed here. Lots of logic and dependencies on resttest.py
    • Challenge: cyclic dependency issues, need to move outputs from macro into objects too, because tests/benchmarks can't import resttest (cyclic dependency issue, since it depends on them)
  2. Fix the nasty parsing of configuration, per https://github.com/svanoort/pyresttest/issues/75
    • Parsing class gets built out with shared extensions, which will do testing and type conversion and docs generation given a list of Options
    • Define an "Optionable" class:
  get_all_options(self)  # Returns a collection of the options allowed here, maybe for docs
  set_option(name, value)  # vs. object.option = value ? (with properties if needed), returns the object itself for fluent use
  parse(self, config)  # parse yaml and return the object
  add_option(self, arguments)  # Add a new config option

Item A1 can occur in a single branch and is fairly isolated. B1 completely depends on it and needs investigation to determine if this approach will work. Item A2 will block development of new features while in progress. B2 is completely dependent on it.