mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
implement /packages/{name} as its own route
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/actions.html. - 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 <kevr@0cost.org>
This commit is contained in:
parent
2d3d03e01e
commit
ae3d302c47
22 changed files with 1166 additions and 254 deletions
51
test/test_packages_util.py
Normal file
51
test/test_packages_util.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
import pytest
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from aurweb import asgi, db
|
||||
from aurweb.models.account_type import USER_ID, AccountType
|
||||
from aurweb.models.official_provider import OFFICIAL_BASE, OfficialProvider
|
||||
from aurweb.models.package import Package
|
||||
from aurweb.models.package_base import PackageBase
|
||||
from aurweb.models.user import User
|
||||
from aurweb.packages import util
|
||||
from aurweb.testing import setup_test_db
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup():
|
||||
setup_test_db(
|
||||
User.__tablename__,
|
||||
Package.__tablename__,
|
||||
PackageBase.__tablename__,
|
||||
OfficialProvider.__tablename__
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def maintainer() -> User:
|
||||
account_type = db.query(AccountType, AccountType.ID == USER_ID).first()
|
||||
yield db.create(User, Username="test_maintainer",
|
||||
Email="test_maintainer@examepl.org",
|
||||
Passwd="testPassword",
|
||||
AccountType=account_type)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def package(maintainer: User) -> Package:
|
||||
pkgbase = db.create(PackageBase, Name="test-pkg", Maintainer=maintainer)
|
||||
yield db.create(Package, Name=pkgbase.Name, PackageBase=pkgbase)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client() -> TestClient:
|
||||
yield TestClient(app=asgi.app)
|
||||
|
||||
|
||||
def test_package_link(client: TestClient, maintainer: User, package: Package):
|
||||
db.create(OfficialProvider,
|
||||
Name=package.Name,
|
||||
Repo="core",
|
||||
Provides=package.Name)
|
||||
expected = f"{OFFICIAL_BASE}/packages/?q={package.Name}"
|
||||
assert util.package_link(package) == expected
|
Loading…
Add table
Add a link
Reference in a new issue