1. 09 Mar, 2022 2 commits
  2. 09 Feb, 2022 1 commit
  3. 01 Jan, 2022 1 commit
    • Kevin Morris's avatar
      feat(testing.requests): add Request.__init__ · 67dd432e
      Kevin Morris authored
      This new constructor is a beginning to making Request a bit more easy
      to deal with for standard testing needs. With this commit, users can
      now specify a `user` and `authenticated` state while constructing a
          request = Request(user=some_user, authenticated=True)
      By default, the `authenticated` kwarg is set to False and `user` is
      set to `aurweb.testing.requests.User()`.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
  4. 09 Dec, 2021 1 commit
  5. 01 Dec, 2021 1 commit
  6. 29 Nov, 2021 6 commits
  7. 17 Nov, 2021 1 commit
    • Kevin Morris's avatar
      change(aurweb): add parallel tests and improve aurweb.db · fa43f6bc
      Kevin Morris authored
      This change utilizes pytest-xdist to perform a multiproc test
      run and reworks aurweb.db's code. We no longer use a global
      engine, session or Session, but we now use a memo of engines
      and sessions as they are requested, based on the PYTEST_CURRENT_TEST
      environment variable, which is available during testing.
      Additionally, this change strips several SQLite components
      out of the Python code-base.
      SQLite is still compatible with PHP and sharness tests, but
      not with our FastAPI implementation.
      More changes:
      - Remove use of aurweb.db.session global in other code.
      - Use new aurweb.db.name() dynamic db name function in env.py.
      - Added 'addopts' to pytest.ini which utilizes multiprocessing.
          - Highly recommended to leave this be or modify `-n auto` to
            `-n {cpu_threads}` where cpu_threads is at least 2.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
  8. 15 Nov, 2021 1 commit
    • Kevin Morris's avatar
      housekeep(fastapi): rework aurweb.db session API · 4103ab49
      Kevin Morris authored
      - Add aurweb.db.get_session()
          - Returns aurweb.db's global `session` instance
          - Provides us a way to change the implementation of the session
            instance without interrupting user code.
      - Use aurweb.db.get_session() in session API methods
      - Add docstrings to session API methods
      - Refactor aurweb.db.delete
          - Normalize aurweb.db.delete to an alias of session.delete
      - Refresh instances in places we depend on their non-PK columns
        being up to date.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
  9. 25 Oct, 2021 1 commit
    • Kevin Morris's avatar
      feat(fastapi): add configurable commit hash display · 0d734eb0
      Kevin Morris authored
      Two new options have been added:
      - [devel] commit_url
          - URL including an %s format specifier that can be used to link
            to a webpage for the commit.
      - [devel] commit_hash
          - HEAD's commit hash (produced via `git rev-parse HEAD`)
      If a `[devel] commit_hash` is configured, a link to the commit based on
      `[devel] commit_url` will be displayed in the aurweb footer in
      the form: `HEAD@<commit_hash>`. If no `[devel] commit_url` is
      configured, a non-linked hash will be displayed.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
  10. 10 Oct, 2021 1 commit
  11. 28 Jul, 2021 1 commit
    • Kevin Morris's avatar
      implement /packages/{name} as its own route · ae3d302c
      Kevin Morris authored
      A few things added with this commit:
      - aurweb.packages.util
          - A module providing package and pkgbase helpers.
      - aurweb.template.register_filter
          - A decorator that can be used to register a filter:
            @register_filter("some_filter") def f(): pass
      Additionally, template partials have been split off a bit
      differently. Changes:
      - /packages/{name} is defined in packages/show.html.
      - partials/packages/package_actions.html is now
      - partials/packages/details.html has been added.
      - partials/packages/comments.html has been added.
      - partials/packages/comment.html has been added.
      - models.dependency_type additions: name and id constants.
      - models.relation_type additions: name and id constants.
      - models.official_provider additions: base official url constant.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
  12. 19 Jun, 2021 1 commit
  13. 11 Jun, 2021 1 commit
  14. 06 Jun, 2021 5 commits
    • Kevin Morris's avatar
      Sanitize and modernize pytests · 38dc2bb9
      Kevin Morris authored
      Some of these tests were written before some of our convenient
      tooling existed. Additionally, some of the tests were not
      cooperating with PEP-8 guidelines or isorted.
      This commit does the following:
          - Replaces all calls to make_(user|session) with
            aurweb.db.create(Model, ...).
          - Replace calls to session.add(...) + session.commit() with
          - Removes the majority of calls to (session|aurweb.db).delete(...).
          - Replaces session.query calls with aurweb.db.query.
          - Initializes all mutable globals in pytest fixture setup().
          - Makes mutable global declarations more concise:
            `var1, var2 = None, None` -> `var1 = var2 = None`
          - Defines a warning exclusion for test/test_ssh_pub_key.py.
          - Removes the aurweb.testing.models module.
          - Removes some useless pytest.fixture yielding.
      As of this commit, developers should use the following guidelines
      when writing tests:
          - Always use aurweb.db.(create|delete|query) for database
            operations, where possible.
          - Always define mutable globals in the style: `var1 = var2 = None`.
          - `yield` the most dependent model in pytest setup fixture **iff**
            you must delete records after test runs to maintain database
            integrity. Example: test/test_account_type.py.
      This all makes the test code look and behave much cleaner.
      Previously, aurweb.testing.setup_test_db was buggy and leaving
      objects around in SQLAlchemy's IdentityMap.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
    • Kevin Morris's avatar
      aurweb.testing.setup_test_db: Expunge objects · 794868b2
      Kevin Morris authored
      This is needed to avoid redundant objects in SQLAlchemy's
      IdentityMap, since we pass a direct .execute to delete
      the tables passed in. Additionally, remove our engine.connect()
      call in favor of relying on the already-established Session.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
    • Kevin Morris's avatar
      add aurweb.time module · 9052688e
      Kevin Morris authored
      This module includes timezone-based utilities for a FastAPI request.
      This commit introduces use of the AURTZ cookie within get_request_timezone.
      This cookie should be set to the user or session's timezone.
      * `make_context` has been modified to parse the request's timezone
        and include the "timezone" and "timezones" variables, along with
        a timezone specified "now" date.
      + Added `Timezone` attribute to aurweb.testing.requests.Request.user.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
    • Kevin Morris's avatar
      add authenticated User LangPreference tracking · 9fdbe3f7
      Kevin Morris authored
      + Use User.LangPreference when there is no set AURSID
        if request.user.is_authenticated is true.
      + Updated post /language to update LangPreference when
      + Restore language during test where we change it.
      + Added the user attribute to aurweb.testing.requests.Request.
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
    • Kevin Morris's avatar
      move aurweb.testing to its own package · 5185df62
      Kevin Morris authored
      + Added aurweb.testing.setup_test_db(*tables)
      + Added aurweb.testing.models.make_user(**kwargs)
      + Added aurweb.testing.models.make_session(**kwargs)
      + Added aurweb.testing.requests.Client
      + Added aurweb.testing.requests.Request
      * Updated test_l10n.py to use our new Request
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>