Skip to content

Commit

Permalink
Merge pull request #91 from smkent/fix-maskedemail-set
Browse files Browse the repository at this point in the history
Fix bugs in Masked Email `/set` method
  • Loading branch information
smkent authored Dec 14, 2022
2 parents 22cfee4 + 13a1c90 commit 0a1dbe3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
3 changes: 2 additions & 1 deletion jmapc/fastmail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
MaskedEmailSet,
MaskedEmailSetResponse,
)
from .maskedemail_models import MaskedEmail
from .maskedemail_models import MaskedEmail, MaskedEmailState

__all__ = [
"MaskedEmail",
"MaskedEmailGet",
"MaskedEmailGetResponse",
"MaskedEmailSet",
"MaskedEmailSetResponse",
"MaskedEmailState",
]
1 change: 1 addition & 0 deletions jmapc/fastmail/maskedemail_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MaskedEmailState(Enum):
class MaskedEmail(Model):
id: Optional[str] = None
email: Optional[str] = None
state: Optional[MaskedEmailState] = None
for_domain: Optional[str] = None
description: Optional[str] = None
last_message_at: Optional[datetime] = field(
Expand Down
6 changes: 3 additions & 3 deletions jmapc/methods/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ class SetResponse(ResponseWithAccount, SetMethod):
created: Optional[Dict[str, Any]]
updated: Optional[Dict[str, Any]]
destroyed: Optional[List[str]]
not_created: Optional[Dict[str, SetError]]
not_updated: Optional[Dict[str, SetError]]
not_destroyed: Optional[Dict[str, SetError]]
not_created: Optional[Dict[str, SetError]] = None
not_updated: Optional[Dict[str, SetError]] = None
not_destroyed: Optional[Dict[str, SetError]] = None


class QueryMethod:
Expand Down
53 changes: 26 additions & 27 deletions tests/methods/test_fastmail_maskedemail.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
MaskedEmailGetResponse,
MaskedEmailSet,
MaskedEmailSetResponse,
MaskedEmailState,
)

from ..utils import expect_jmap_call
Expand Down Expand Up @@ -92,14 +93,14 @@ def test_maskedemail_set(
"accountId": "u1138",
"create": {
"create": {
"email": "pk.fire@ness.example.com",
"email": "pk.fire2187@ness.example.com",
"forDomain": "ness.example.com",
"description": (
"Masked Email (pk.fire@ness.example.com)"
"Masked Email (pk.fire2187@ness.example.com)"
),
"lastMessageAt": "1994-08-24T12:01:02Z",
"createdAt": "1994-08-24T12:01:02Z",
"createdBy": "ness",
"createdBy": "API Token: onett-dev",
},
},
},
Expand All @@ -117,26 +118,25 @@ def test_maskedemail_set(
"MaskedEmail/set",
{
"accountId": "u1138",
"oldState": None,
"newState": None,
"created": {
"create": {
"id": "masked-42",
"email": "pk.fire@ness.example.com",
"url": None,
"state": "pending",
"forDomain": "ness.example.com",
"description": (
"Masked Email (pk.fire@ness.example.com)"
"Masked Email (pk.fire2187@ness.example.com)"
),
"lastMessageAt": "1994-08-24T12:01:02Z",
"createdAt": "1994-08-24T12:01:02Z",
"createdBy": "ness",
"email": "pk.fire2187@ness.example.com",
"createdBy": "API Token: onett-dev",
"lastMessageAt": None,
}
},
"destroyed": None,
"newState": "2",
"notCreated": None,
"notDestroyed": None,
"notUpdated": None,
"oldState": "1",
"updated": None,
"updated": {},
"destroyed": [],
},
"single.MaskedEmail/set",
]
Expand All @@ -149,40 +149,39 @@ def test_maskedemail_set(
create=dict(
create=MaskedEmail(
id=None,
email="pk.fire@ness.example.com",
email="pk.fire2187@ness.example.com",
for_domain="ness.example.com",
description="Masked Email (pk.fire@ness.example.com)",
description="Masked Email (pk.fire2187@ness.example.com)",
last_message_at=datetime(
1994, 8, 24, 12, 1, 2, tzinfo=timezone.utc
),
created_at=datetime(
1994, 8, 24, 12, 1, 2, tzinfo=timezone.utc
),
created_by="ness",
created_by="API Token: onett-dev",
)
)
)
) == MaskedEmailSetResponse(
account_id="u1138",
old_state="1",
new_state="2",
old_state=None,
new_state=None,
created=dict(
create=MaskedEmail(
id="masked-42",
email="pk.fire@ness.example.com",
email="pk.fire2187@ness.example.com",
state=MaskedEmailState.PENDING,
for_domain="ness.example.com",
description="Masked Email (pk.fire@ness.example.com)",
last_message_at=datetime(
1994, 8, 24, 12, 1, 2, tzinfo=timezone.utc
),
description="Masked Email (pk.fire2187@ness.example.com)",
last_message_at=None,
created_at=datetime(
1994, 8, 24, 12, 1, 2, tzinfo=timezone.utc
),
created_by="ness",
created_by="API Token: onett-dev",
),
),
updated=None,
destroyed=None,
updated={},
destroyed=[],
not_created=None,
not_updated=None,
not_destroyed=None,
Expand Down

0 comments on commit 0a1dbe3

Please sign in to comment.