-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
|
||
from apps.odk_publish.etl.odk.publish import ProjectAppUserAssignment | ||
from apps.odk_publish.etl.odk.qrcode import build_collect_settings, create_app_user_qrcode | ||
|
||
|
||
class TestCollectSettings: | ||
@pytest.fixture | ||
def app_user(self) -> ProjectAppUserAssignment: | ||
return ProjectAppUserAssignment( | ||
projectId=1, | ||
id=1, | ||
type=None, | ||
displayName="10000", | ||
createdAt="2025-01-07T14:18:37.300Z", | ||
updatedAt=None, | ||
deletedAt=None, | ||
token="token1", | ||
) | ||
|
||
def test_build_collect_settings(self, app_user): | ||
collect_settings = build_collect_settings( | ||
app_user=app_user, | ||
base_url="https://central", | ||
project_id=1, | ||
project_name_prefix="Project", | ||
language="en", | ||
) | ||
assert collect_settings["general"]["server_url"] == "https://central/key/token1/projects/1" | ||
assert collect_settings["general"]["username"] == app_user.displayName | ||
assert collect_settings["general"]["app_language"] == "en" | ||
assert collect_settings["project"]["name"] == "Project: 10000 (en)" | ||
|
||
def test_create_app_user_qrcode(self, app_user): | ||
qr_code = create_app_user_qrcode( | ||
app_user=app_user, | ||
base_url="https://central", | ||
project_id=1, | ||
project_name_prefix="Project", | ||
language="en", | ||
) | ||
assert qr_code.getvalue()[:4] == b"\x89PNG" |