mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
test: update tests to work with TUVote.Decision
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
a29701459c
commit
cf4ab696d0
2 changed files with 10 additions and 7 deletions
|
@ -11,7 +11,7 @@ from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from aurweb import config, db, filters, time
|
from aurweb import config, db, filters, time
|
||||||
from aurweb.models.account_type import DEVELOPER_ID, TRUSTED_USER_ID, AccountType
|
from aurweb.models.account_type import DEVELOPER_ID, TRUSTED_USER_ID, AccountType
|
||||||
from aurweb.models.tu_vote import TUVote
|
from aurweb.models.tu_vote import YES_ID, TUVote
|
||||||
from aurweb.models.tu_voteinfo import TUVoteInfo
|
from aurweb.models.tu_voteinfo import TUVoteInfo
|
||||||
from aurweb.models.user import User
|
from aurweb.models.user import User
|
||||||
from aurweb.testing.requests import Request
|
from aurweb.testing.requests import Request
|
||||||
|
@ -173,7 +173,7 @@ def test_tu_empty_index(client, tu_user):
|
||||||
assert len(tables) == 0
|
assert len(tables) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_tu_index(client, tu_user):
|
def test_tu_index(client: TestClient, tu_user: User):
|
||||||
ts = time.utcnow()
|
ts = time.utcnow()
|
||||||
|
|
||||||
# Create some test votes: (Agenda, Start, End).
|
# Create some test votes: (Agenda, Start, End).
|
||||||
|
@ -197,7 +197,8 @@ def test_tu_index(client, tu_user):
|
||||||
vote_record = vote_records[1]
|
vote_record = vote_records[1]
|
||||||
vote_record.Yes += 1
|
vote_record.Yes += 1
|
||||||
vote_record.ActiveTUs += 1
|
vote_record.ActiveTUs += 1
|
||||||
db.create(TUVote, VoteInfo=vote_record, User=tu_user)
|
db.create(TUVote, VoteInfo=vote_record, User=tu_user,
|
||||||
|
Decision=YES_ID)
|
||||||
|
|
||||||
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
|
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
|
||||||
with client as request:
|
with client as request:
|
||||||
|
@ -462,8 +463,8 @@ def test_tu_index_last_votes(client: TestClient, tu_user: User, tu_user2: User,
|
||||||
Submitter=tu_user)
|
Submitter=tu_user)
|
||||||
|
|
||||||
# Create a vote on it from tu_user.
|
# Create a vote on it from tu_user.
|
||||||
db.create(TUVote, VoteInfo=voteinfo, User=tu_user)
|
db.create(TUVote, VoteInfo=voteinfo, User=tu_user, Decision=YES_ID)
|
||||||
db.create(TUVote, VoteInfo=voteinfo, User=tu_user2)
|
db.create(TUVote, VoteInfo=voteinfo, User=tu_user2, Decision=YES_ID)
|
||||||
|
|
||||||
# Now, check that tu_user got populated in the .last-votes table.
|
# Now, check that tu_user got populated in the .last-votes table.
|
||||||
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
|
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
|
||||||
|
@ -575,7 +576,7 @@ def test_tu_running_proposal(client: TestClient,
|
||||||
|
|
||||||
# Create a vote.
|
# Create a vote.
|
||||||
with db.begin():
|
with db.begin():
|
||||||
db.create(TUVote, VoteInfo=voteinfo, User=tu_user)
|
db.create(TUVote, VoteInfo=voteinfo, User=tu_user, Decision=YES_ID)
|
||||||
voteinfo.ActiveTUs += 1
|
voteinfo.ActiveTUs += 1
|
||||||
voteinfo.Yes += 1
|
voteinfo.Yes += 1
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import pytest
|
||||||
from aurweb import config, db, time
|
from aurweb import config, db, time
|
||||||
from aurweb.models import TUVote, TUVoteInfo, User
|
from aurweb.models import TUVote, TUVoteInfo, User
|
||||||
from aurweb.models.account_type import TRUSTED_USER_ID
|
from aurweb.models.account_type import TRUSTED_USER_ID
|
||||||
|
from aurweb.models.tu_vote import YES_ID
|
||||||
from aurweb.scripts import tuvotereminder as reminder
|
from aurweb.scripts import tuvotereminder as reminder
|
||||||
from aurweb.testing.email import Email
|
from aurweb.testing.email import Email
|
||||||
|
|
||||||
|
@ -13,7 +14,8 @@ aur_location = config.get("options", "aur_location")
|
||||||
|
|
||||||
def create_vote(user: User, voteinfo: TUVoteInfo) -> TUVote:
|
def create_vote(user: User, voteinfo: TUVoteInfo) -> TUVote:
|
||||||
with db.begin():
|
with db.begin():
|
||||||
vote = db.create(TUVote, User=user, VoteID=voteinfo.ID)
|
vote = db.create(TUVote, User=user, VoteID=voteinfo.ID,
|
||||||
|
Decision=YES_ID)
|
||||||
return vote
|
return vote
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue