Skip to content

Commit

Permalink
Fix tests and create_test_db script
Browse files Browse the repository at this point in the history
  • Loading branch information
kaenganxt committed Oct 23, 2023
1 parent 88f4cea commit 5790dbc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ekklesia_portal/lib/vvvote/election_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

import random
from uuid import uuid4

Expand Down Expand Up @@ -49,8 +51,8 @@ def ballot_to_vvvote_question(ballot):

def get_ballot_sort_key(ballot):
props = list(ballot.propositions)
props.sort(key=lambda prop: prop.qualified_at)
return props[0].qualified_at
props.sort(key=lambda prop: prop.qualified_at or datetime.now())
return props[0].qualified_at or datetime.now()


def voting_phase_to_vvvote_election_config(module_config, phase) -> vvvote_schema.ElectionConfig:
Expand Down
3 changes: 1 addition & 2 deletions tests/create_test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typer import Option, confirm, Exit

import ekklesia_common.logging
from ekklesia_common.ekklesia_auth import OAuthToken

DOCUMENT_WP = '''# Wahlprogramm
Expand Down Expand Up @@ -115,7 +114,7 @@ def main(
# local import because we have to set up the database stuff before that
from ekklesia_portal.datamodel import (
Argument, ArgumentRelation, ArgumentVote, Ballot, CustomizableText, Department, DepartmentMember, Document,
Group, Policy, Proposition, PropositionType, SubjectArea, Supporter, Tag, User, UserPassword, UserProfile,
Group, OAuthToken, Policy, Proposition, PropositionType, SubjectArea, Supporter, Tag, User, UserPassword, UserProfile,
VotingPhase, VotingPhaseType
)

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/vvvote/test_election_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_ballot_to_vvvote_question(db_session, ballot, proposition_factory):
proposition = proposition_factory(ballot=ballot)
question = ballot_to_vvvote_question(ballot)
assert question.questionID == 1
assert question.questionID == ballot.id
assert question.options[0].optionTitle == proposition.title
assert question.options[0].optionDesc == proposition.content
assert question.options[0].reasons == proposition.motivation
Expand Down

0 comments on commit 5790dbc

Please sign in to comment.