[aur-dev] [PATCH 1/3] tuvotereminder: Wait for notify processes
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- scripts/tuvotereminder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tuvotereminder.py b/scripts/tuvotereminder.py index a053608..97b1d12 100755 --- a/scripts/tuvotereminder.py +++ b/scripts/tuvotereminder.py @@ -21,7 +21,7 @@ def main(): [filter_from, filter_to]) for vote_id in [row[0] for row in cur.fetchall()]: - subprocess.Popen((notify_cmd, 'tu-vote-reminder', str(vote_id))) + subprocess.Popen((notify_cmd, 'tu-vote-reminder', str(vote_id))).wait() if __name__ == '__main__': -- 2.10.0
Instead of only checking whether the notification script is called with the correct parameters, actually invoke the real notify script and check whether proper notifications are generated. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- test/setup.sh | 14 ++++++++++---- test/t2200-tuvotereminder.sh | 11 +++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test/setup.sh b/test/setup.sh index e379ada..cd42479 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -15,6 +15,7 @@ MKPKGLISTS="$TOPLEVEL/scripts/mkpkglists.py" TUVOTEREMINDER="$TOPLEVEL/scripts/tuvotereminder.py" PKGMAINT="$TOPLEVEL/scripts/pkgmaint.py" AURBLUP="$TOPLEVEL/scripts/aurblup.py" +NOTIFY="$TOPLEVEL/scripts/notify.py" # Create the configuration file and a dummy notification script. cat >config <<-EOF @@ -23,11 +24,16 @@ backend = sqlite name = aur.db [options] +aur_location = https://aur.archlinux.org +aur_request_ml = aur-requests@archlinux.org enable-maintenance = 0 maintenance-exceptions = 127.0.0.1 [notifications] -notify-cmd = ./notify.sh +notify-cmd = $NOTIFY +sendmail = ./sendmail.sh +sender = notify@aur.archlinux.org +reply-to = noreply@aur.archlinux.org [auth] valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519 @@ -55,11 +61,11 @@ packagesfile = packages.gz pkgbasefile = pkgbase.gz EOF -cat >notify.sh <<-\EOF +cat >sendmail.sh <<-\EOF #!/bin/sh -echo $* >>notify.out +cat >>sendmail.out EOF -chmod +x notify.sh +chmod +x sendmail.sh cat >git-shell.sh <<-\EOF #!/bin/sh diff --git a/test/t2200-tuvotereminder.sh b/test/t2200-tuvotereminder.sh index 438c0c3..8477c92 100755 --- a/test/t2200-tuvotereminder.sh +++ b/test/t2200-tuvotereminder.sh @@ -14,13 +14,12 @@ test_expect_success 'Test Trusted User vote reminders.' ' INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (3, "Lorem ipsum.", "user", 0, $tomorrow, 0.00, 2); INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (4, "Lorem ipsum.", "user", 0, $threedays, 0.00, 2); EOD - >notify.out && + >sendmail.out && "$TUVOTEREMINDER" && - cat <<-EOD >expected && - tu-vote-reminder 2 - tu-vote-reminder 3 - EOD - test_cmp notify.out expected + grep -q "Proposal 2" sendmail.out && + grep -q "Proposal 3" sendmail.out && + test_must_fail grep -q "Proposal 1" sendmail.out && + test_must_fail grep -q "Proposal 4" sendmail.out ' test_done -- 2.10.0
Add a test to make sure that Trusted Users, who already voted on a proposal, do not receive any reminders. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- test/setup.sh | 3 +++ test/t2200-tuvotereminder.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/test/setup.sh b/test/setup.sh index cd42479..dc9cff2 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -115,6 +115,9 @@ echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (3, echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (4, 'user2', '!', 'user2@localhost', 1);" | sqlite3 aur.db echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (5, 'user3', '!', 'user3@localhost', 1);" | sqlite3 aur.db echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (6, 'user4', '!', 'user4@localhost', 1);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (7, 'tu2', '!', 'tu2@localhost', 2);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (8, 'tu3', '!', 'tu3@localhost', 2);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (9, 'tu4', '!', 'tu4@localhost', 2);" | sqlite3 aur.db echo "INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey) VALUES (1, '$AUTH_FINGERPRINT_USER', '$AUTH_KEYTYPE_USER $AUTH_KEYTEXT_USER');" | sqlite3 aur.db echo "INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey) VALUES (2, '$AUTH_FINGERPRINT_TU', '$AUTH_KEYTYPE_TU $AUTH_KEYTEXT_TU');" | sqlite3 aur.db diff --git a/test/t2200-tuvotereminder.sh b/test/t2200-tuvotereminder.sh index 8477c92..c82ce87 100755 --- a/test/t2200-tuvotereminder.sh +++ b/test/t2200-tuvotereminder.sh @@ -22,4 +22,32 @@ test_expect_success 'Test Trusted User vote reminders.' ' test_must_fail grep -q "Proposal 4" sendmail.out ' +test_expect_success 'Check that only TUs who did not vote receive reminders.' ' + cat <<-EOD | sqlite3 aur.db && + INSERT INTO TU_Votes (VoteID, UserID) VALUES (1, 2); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (2, 2); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (3, 2); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (4, 2); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (1, 7); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (3, 7); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (2, 8); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (4, 8); + INSERT INTO TU_Votes (VoteID, UserID) VALUES (1, 9); + EOD + >sendmail.out && + "$TUVOTEREMINDER" && + cat <<-EOD >expected && + Subject: TU Vote Reminder: Proposal 2 + To: tu2@localhost + Subject: TU Vote Reminder: Proposal 2 + To: tu4@localhost + Subject: TU Vote Reminder: Proposal 3 + To: tu3@localhost + Subject: TU Vote Reminder: Proposal 3 + To: tu4@localhost + EOD + grep "^\(Subject\|To\)" sendmail.out >sendmail.parts && + test_cmp sendmail.parts expected +' + test_done -- 2.10.0
participants (1)
-
Lukas Fleischer