Skip to content

Commit

Permalink
Add test for enter/leave commands
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth committed Jun 3, 2022
1 parent cd329aa commit ff350bd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,25 @@ jobs:
postgresql password: pass
if: matrix.database == 'postgres'

- name: Setup postgres dependency
run: |
source env/bin/activate
poetry add psycopg2
if: matrix.database == 'postgres'

#- uses: mirromutth/[email protected]
# with:
# mysql database: 'myHPI'
# mysql root password: 'root'
# if: matrix.database == 'mysql'

- name: Setup mysql
run: |
sudo systemctl start mysql.service
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot -proot -Dmysql
echo "CREATE DATABASE myHPI;" | mysql -uroot -proot
source env/bin/activate
poetry add mysqlclient
if: matrix.database == 'mysql'

- name: Test apps
Expand Down
5 changes: 1 addition & 4 deletions myhpi/wagtail_markdown/minutes_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ def __init__(self, *args, **kwargs):
r"\|enter\|\(([0-9:]+)\)\(([^\)\(]+)\)(\((?P<mean_of_participation>.*?)\))?",
self.enterify,
),
(
r"\|leave\|\(([0-9:]+)\)\(([^\)\(]+)\)",
self.leavify
),
(r"\|leave\|\(([0-9:]+)\)\(([^\)\(]+)\)", self.leavify),
]

def enter_or_leavify(self, match, event):
Expand Down
28 changes: 28 additions & 0 deletions tests/test_minutes_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import django
import pytest
from django.test import TestCase

django.setup()

from myhpi.wagtail_markdown.minutes_extensions import EnterLeavePreprocessor


class TestMinuteExtensions(TestCase):
def test_enter(self):
elp = EnterLeavePreprocessor()
text = [
"|enter|(12:00)(First Last)",
"|enter|(12:00)(Prof. First Last)",
"|enter|(12:00)(Prof. First Last)(Means)",
"|leave|(12:00)(Prof. First Last)",
]
result = elp.run(text)
self.assertEqual(
result,
[
"*12:00: First Last enters the meeting* ",
"*12:00: Prof. First Last enters the meeting* ",
"*12:00: Prof. First Last enters the meeting via Means* ",
"*12:00: Prof. First Last leaves the meeting* ",
],
)

0 comments on commit ff350bd

Please sign in to comment.