-
Notifications
You must be signed in to change notification settings - Fork 339
Mlkit fix date handling2 #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
fcc3b2d
5c923ce
16815e2
efb44ae
b68f8fc
bb0b146
3fead5f
6e2c1eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
|
||
"""Test cases for the firebase_admin.ml module.""" | ||
|
||
import datetime | ||
import json | ||
import pytest | ||
|
||
|
@@ -27,25 +26,12 @@ | |
PROJECT_ID = 'myProject1' | ||
PAGE_TOKEN = 'pageToken' | ||
NEXT_PAGE_TOKEN = 'nextPageToken' | ||
CREATE_TIME_SECONDS = 1566426374 | ||
CREATE_TIME_SECONDS_2 = 1566426385 | ||
CREATE_TIME_JSON = { | ||
'seconds': CREATE_TIME_SECONDS | ||
} | ||
CREATE_TIME_DATETIME = datetime.datetime.fromtimestamp(CREATE_TIME_SECONDS) | ||
CREATE_TIME_JSON_2 = { | ||
'seconds': CREATE_TIME_SECONDS_2 | ||
} | ||
CREATE_TIME = '2020-01-21T20:44:27.392932Z' | ||
CREATE_TIME_2 = '2020-01-21T21:44:27.392932Z' | ||
|
||
UPDATE_TIME = '2020-01-21T22:45:29.392932Z' | ||
UPDATE_TIME_2 = '2020-01-21T23:45:29.392932Z' | ||
|
||
UPDATE_TIME_SECONDS = 1566426678 | ||
UPDATE_TIME_SECONDS_2 = 1566426691 | ||
UPDATE_TIME_JSON = { | ||
'seconds': UPDATE_TIME_SECONDS | ||
} | ||
UPDATE_TIME_DATETIME = datetime.datetime.fromtimestamp(UPDATE_TIME_SECONDS) | ||
UPDATE_TIME_JSON_2 = { | ||
'seconds': UPDATE_TIME_SECONDS_2 | ||
} | ||
ETAG = '33a64df551425fcc55e4d42a148795d9f25f89d4' | ||
MODEL_HASH = '987987a98b98798d098098e09809fc0893897' | ||
TAG_1 = 'Tag1' | ||
|
@@ -130,8 +116,8 @@ | |
CREATED_UPDATED_MODEL_JSON_1 = { | ||
'name': MODEL_NAME_1, | ||
'displayName': DISPLAY_NAME_1, | ||
'createTime': CREATE_TIME_JSON, | ||
'updateTime': UPDATE_TIME_JSON, | ||
'createTime': CREATE_TIME, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these 2 values ever be not set in response? At least the parsing logic assumes so. Might want to add a test case for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They will always be set in the response. |
||
'updateTime': UPDATE_TIME, | ||
'state': MODEL_STATE_ERROR_JSON, | ||
'etag': ETAG, | ||
'modelHash': MODEL_HASH, | ||
|
@@ -142,17 +128,17 @@ | |
LOCKED_MODEL_JSON_1 = { | ||
'name': MODEL_NAME_1, | ||
'displayName': DISPLAY_NAME_1, | ||
'createTime': CREATE_TIME_JSON, | ||
'updateTime': UPDATE_TIME_JSON, | ||
'createTime': CREATE_TIME, | ||
'updateTime': UPDATE_TIME, | ||
'tags': TAGS, | ||
'activeOperations': [OPERATION_NOT_DONE_JSON_1] | ||
} | ||
|
||
LOCKED_MODEL_JSON_2 = { | ||
'name': MODEL_NAME_1, | ||
'displayName': DISPLAY_NAME_2, | ||
'createTime': CREATE_TIME_JSON_2, | ||
'updateTime': UPDATE_TIME_JSON_2, | ||
'createTime': CREATE_TIME_2, | ||
'updateTime': UPDATE_TIME_2, | ||
'tags': TAGS_2, | ||
'activeOperations': [OPERATION_NOT_DONE_JSON_1] | ||
} | ||
|
@@ -183,8 +169,8 @@ | |
FULL_MODEL_ERR_STATE_LRO_JSON = { | ||
'name': MODEL_NAME_1, | ||
'displayName': DISPLAY_NAME_1, | ||
'createTime': CREATE_TIME_JSON, | ||
'updateTime': UPDATE_TIME_JSON, | ||
'createTime': CREATE_TIME, | ||
'updateTime': UPDATE_TIME, | ||
'state': MODEL_STATE_ERROR_JSON, | ||
'etag': ETAG, | ||
'modelHash': MODEL_HASH, | ||
|
@@ -194,8 +180,8 @@ | |
FULL_MODEL_PUBLISHED_JSON = { | ||
'name': MODEL_NAME_1, | ||
'displayName': DISPLAY_NAME_1, | ||
'createTime': CREATE_TIME_JSON, | ||
'updateTime': UPDATE_TIME_JSON, | ||
'createTime': CREATE_TIME, | ||
'updateTime': UPDATE_TIME, | ||
'state': MODEL_STATE_PUBLISHED_JSON, | ||
'etag': ETAG, | ||
'modelHash': MODEL_HASH, | ||
|
@@ -364,8 +350,8 @@ def test_model_success_err_state_lro(self): | |
model = ml.Model.from_dict(FULL_MODEL_ERR_STATE_LRO_JSON) | ||
assert model.model_id == MODEL_ID_1 | ||
assert model.display_name == DISPLAY_NAME_1 | ||
assert model.create_time == CREATE_TIME_DATETIME | ||
assert model.update_time == UPDATE_TIME_DATETIME | ||
assert model.create_time == CREATE_TIME | ||
assert model.update_time == UPDATE_TIME | ||
assert model.validation_error == VALIDATION_ERROR_MSG | ||
assert model.published is False | ||
assert model.etag == ETAG | ||
|
@@ -379,8 +365,8 @@ def test_model_success_published(self): | |
model = ml.Model.from_dict(FULL_MODEL_PUBLISHED_JSON) | ||
assert model.model_id == MODEL_ID_1 | ||
assert model.display_name == DISPLAY_NAME_1 | ||
assert model.create_time == CREATE_TIME_DATETIME | ||
assert model.update_time == UPDATE_TIME_DATETIME | ||
assert model.create_time == CREATE_TIME | ||
assert model.update_time == UPDATE_TIME | ||
assert model.validation_error is None | ||
assert model.published is True | ||
assert model.etag == ETAG | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally expose timestamps as milliseconds since epoch values in Python. We might want to retain that behavior here as well. String timestamps are kind of awkward in Python (since it requires the user to handle the timezone and the format of the string).
firebase-admin-python/firebase_admin/_user_mgt.py
Lines 51 to 66 in 00cf1d3
What did we agree to in the API review for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Millis. I changed it to do the conversion. Thanks.