• 
      

    Add new methods and state for API test object population.

    Review Request #13391 — Created Oct. 30, 2023 and submitted — Latest diff uploaded

    Information

    Review Board
    release-5.0.x

    Reviewers

    When the current API test suite was first implemented, we had test
    suites populate their objects and return some state in
    setup_basic_<httpmethod>_test() methods. That state was returned as
    tuples, making it hard to expand upon this.

    Now that we have dictionaries that store state for an API test, it's
    time to gradually move away from these methods. Subclasses can now
    define an equivalent populate_*_test_objects() method, which takes in
    the setup_state and some parameters for controlling the population,
    and then updates setup_state with the new data. This ensures
    everything is stored in one place, and gives us room for expansion.

    New keys were added to setup_state for upcoming test changes. This
    includes:

    • auth_user: The logged-in user.
    • with_local_site: Whether testing is done on a Local Site.
    • local_site: The instance of the Local Site.
    • local_site_name: The name of the Local Site.
    • local_sites_in_db: Whether there are Local Sites in the database.
    • owner: The user owning objects being modified/deleted in a test.
      This may differ from auth_user, and replaces user.
    • test_objects: Arbitrary key/value storage for tests, used for
      upcoming comparison and query assertion support.

    And authentication state has been fixed when trying to log in with an
    explicit user who is not already logged in.

    This test restructuring is necessary for getting us to the point of
    having standardized query assertions, to help work toward peak API
    performance.

    Unit tests pass.

    Made use of all the new functionality in the upcoming API query
    assertion code.

    Commits

    Files