feat(fastapi): add id="conflicts" to package details conflicts

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-11-11 19:53:50 -08:00
parent e8e9edbb21
commit 7aa959150e
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
2 changed files with 13 additions and 2 deletions

View file

@ -70,7 +70,7 @@
</tr> </tr>
{% endif %} {% endif %}
{% if show_package_details and conflicts and conflicts.count() %} {% if show_package_details and conflicts and conflicts.count() %}
<tr> <tr id="conflicts">
<th>{{ "Conflicts" | tr }}:</th> <th>{{ "Conflicts" | tr }}:</th>
<td class="wrap"> <td class="wrap">
{{ conflicts.all() | join(', ', attribute='RelName') }} {{ conflicts.all() | join(', ', attribute='RelName') }}

View file

@ -24,7 +24,7 @@ from aurweb.models.package_notification import PackageNotification
from aurweb.models.package_relation import PackageRelation from aurweb.models.package_relation import PackageRelation
from aurweb.models.package_request import ACCEPTED_ID, REJECTED_ID, PackageRequest from aurweb.models.package_request import ACCEPTED_ID, REJECTED_ID, PackageRequest
from aurweb.models.package_vote import PackageVote from aurweb.models.package_vote import PackageVote
from aurweb.models.relation_type import PROVIDES_ID, REPLACES_ID, RelationType from aurweb.models.relation_type import CONFLICTS_ID, PROVIDES_ID, REPLACES_ID, RelationType
from aurweb.models.request_type import DELETION_ID, MERGE_ID, RequestType from aurweb.models.request_type import DELETION_ID, MERGE_ID, RequestType
from aurweb.models.user import User from aurweb.models.user import User
from aurweb.testing import setup_test_db from aurweb.testing import setup_test_db
@ -233,6 +233,13 @@ def test_package(client: TestClient, package: Package):
RelTypeID=REPLACES_ID, RelTypeID=REPLACES_ID,
RelName="test_replacer2") RelName="test_replacer2")
db.create(PackageRelation, PackageID=package.ID,
RelTypeID=CONFLICTS_ID,
RelName="test_conflict1")
db.create(PackageRelation, PackageID=package.ID,
RelTypeID=CONFLICTS_ID,
RelName="test_conflict2")
with client as request: with client as request:
resp = request.get(package_endpoint(package)) resp = request.get(package_endpoint(package))
assert resp.status_code == int(HTTPStatus.OK) assert resp.status_code == int(HTTPStatus.OK)
@ -261,6 +268,10 @@ def test_package(client: TestClient, package: Package):
expected = ["test_replacer1", "test_replacer2"] expected = ["test_replacer1", "test_replacer2"]
assert replaces[0].text.strip() == ", ".join(expected) assert replaces[0].text.strip() == ", ".join(expected)
conflicts = root.xpath('//tr[@id="conflicts"]/td')
expected = ["test_conflict1", "test_conflict2"]
assert conflicts[0].text.strip() == ", ".join(expected)
def test_package_comments(client: TestClient, user: User, package: Package): def test_package_comments(client: TestClient, user: User, package: Package):
now = (datetime.utcnow().timestamp()) now = (datetime.utcnow().timestamp())