forked from devartis/passbook
-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
bbf29a6
commit fd44285
Showing
6 changed files
with
91 additions
and
6 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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
from pydantic import BaseModel | ||
from wallet.PassProps.Alignment import Alignment | ||
from typing import Optional, Union | ||
|
||
|
||
class FieldProps(BaseModel): | ||
key: str | ||
value: str | ||
label: str | None = None | ||
attributed_value: str | None = None | ||
change_message: str | None = None | ||
text_alignment: Alignment | str = Alignment.LEFT | ||
label: Optional[str] = None | ||
attributed_value: Optional[str] = None | ||
change_message: Optional[str] = None | ||
text_alignment: Optional[Union[Alignment, str]] = Alignment.LEFT | ||
|
||
class Config: | ||
arbitrary_types_allowed = True |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,83 @@ | ||
from wallet.PassStyles.StoreCard import StoreCard | ||
from wallet.Pass import Pass | ||
from pytest import raises | ||
|
||
card = StoreCard() | ||
pass_file = Pass( | ||
**{ | ||
"pass_information": card, | ||
"pass_type_identifier": "pass_type_identifier", | ||
"organization_name": "organization_name", | ||
"team_identifier": "team_identifier", | ||
} | ||
) | ||
|
||
pass_file.logoText = "Sharks" | ||
|
||
# charge_response.id is trackable via the Stripe dashboard | ||
pass_file.serialNumber = "12345" | ||
pass_file.description = "some discription" | ||
pass_file.backgroundColor = "rgb(38, 93, 205)" | ||
pass_file.foregroundColor = "rgb(255, 255, 255)" | ||
pass_file.labelColor = "rgb(189, 189, 189)" | ||
|
||
pass_file_as_json = b'{"storeCard": {"headerFields": [], "primaryFields": [], "secondaryFields": [], "backFields": [], "auxiliaryFields": []}, "description": "some discription", "formatVersion": 1, "organizationName": "organization_name", "passTypeIdentifier": "pass_type_identifier", "serialNumber": "12345", "teamIdentifier": "team_identifier", "backgroundColor": "rgb(38, 93, 205)", "foregroundColor": "rgb(255, 255, 255)", "labelColor": "rgb(189, 189, 189)", "logoText": "Sharks"}' | ||
pass_file_manifest = b'{"pass.json": "3642041e506fd6a623a0bb00eb4fb8584e0264f9", "icon.png": "f6d49b2c2c03d2ef82e4d11841b60b58c7f18979", "logo.png": "f6d49b2c2c03d2ef82e4d11841b60b58c7f18979", "strip.png": "bf930d6ba371b42a461655c4b9719398e2068702"}' | ||
shark_icon = "wallet/test/test_assets/_shark-icon.png" | ||
sea_img = "wallet/test/test_assets/_sea.jpg" | ||
|
||
|
||
def test_add_files_to_pass(): | ||
|
||
pass_file.add_file("icon.png", open(shark_icon, "rb")) | ||
pass_file.add_file("logo.png", open(shark_icon, "rb")) | ||
|
||
pass_file.add_file("strip.png", open(sea_img, "rb")) | ||
|
||
files = [file for file in pass_file._files.keys()] | ||
|
||
assert files[0] == "icon.png" | ||
assert files[1] == "logo.png" | ||
assert files[2] == "strip.png" | ||
|
||
|
||
def test_add_bad_files_to_pass(): | ||
with raises(FileNotFoundError): | ||
pass_file.add_file("icon.png", open("wallet/test/logo.png", "rb")) | ||
with raises(FileNotFoundError): | ||
pass_file.add_file("icon.png", open("", "rb")) | ||
|
||
|
||
def test_create_pass_json(): | ||
pass_as_json = pass_file._create_pass_json() | ||
assert pass_as_json == pass_file_as_json | ||
|
||
|
||
def test_create_manifest(): | ||
pass_manifest = pass_file._create_manifest(pass_file_as_json) | ||
|
||
assert pass_manifest == pass_file_manifest | ||
|
||
|
||
def test_json_dict(): | ||
json_pass = pass_file.json_dict() | ||
|
||
assert json_pass == { | ||
"storeCard": { | ||
"headerFields": [], | ||
"primaryFields": [], | ||
"secondaryFields": [], | ||
"backFields": [], | ||
"auxiliaryFields": [], | ||
}, | ||
"description": "some discription", | ||
"formatVersion": 1, | ||
"organizationName": "organization_name", | ||
"passTypeIdentifier": "pass_type_identifier", | ||
"serialNumber": "12345", | ||
"teamIdentifier": "team_identifier", | ||
"backgroundColor": "rgb(38, 93, 205)", | ||
"foregroundColor": "rgb(255, 255, 255)", | ||
"labelColor": "rgb(189, 189, 189)", | ||
"logoText": "Sharks", | ||
} |