aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristopher Wilcox <crwilcox@google.com>2019-05-20 12:20:32 -0700
committerGitHub <noreply@github.com>2019-05-20 12:20:32 -0700
commit37a4ac61e49d9283fd819dd5e9b4850e2182eb1f (patch)
tree656ece9b13993de58a13a93767f3ef3d52703bd8 /tests
parentf1693da3aeada2373e56036892c0ff854f4ca9c4 (diff)
downloadpython-api-core-37a4ac61e49d9283fd819dd5e9b4850e2182eb1f.tar.gz
Add parameterized test for from_rfc3339 with nanos (#7675)
* Add parameterized test for from_rfc3339 with nanos
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_datetime_helpers.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_datetime_helpers.py b/tests/unit/test_datetime_helpers.py
index a53086e..4d138c8 100644
--- a/tests/unit/test_datetime_helpers.py
+++ b/tests/unit/test_datetime_helpers.py
@@ -270,6 +270,24 @@ class Test_DateTimeWithNanos(object):
assert stamp == expected
@staticmethod
+ @pytest.mark.parametrize(
+ "fractional, nanos",
+ [
+ ("12345678", 123456780),
+ ("1234567", 123456700),
+ ("123456", 123456000),
+ ("12345", 123450000),
+ ("1234", 123400000),
+ ("123", 123000000),
+ ("12", 120000000),
+ ("1", 100000000),
+ ],
+ )
+ def test_from_rfc3339_test_nanoseconds(fractional, nanos):
+ value = "2009-12-17T12:44:32.{}Z".format(fractional)
+ assert datetime_helpers.DatetimeWithNanoseconds.from_rfc3339(value).nanosecond == nanos
+
+ @staticmethod
def test_timestamp_pb_wo_nanos_naive():
stamp = datetime_helpers.DatetimeWithNanoseconds(
2016, 12, 20, 21, 13, 47, 123456)