Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions runtimeconfig/tests/unit/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _make_one(self, *args, **kw):

def _verifyResourceProperties(self, variable, resource):
import base64
from google.cloud._helpers import _rfc3339_to_datetime
from google.api_core import datetime_helpers

if 'name' in resource:
self.assertEqual(variable.full_name, resource['name'])
Expand All @@ -50,7 +50,8 @@ def _verifyResourceProperties(self, variable, resource):
if 'updateTime' in resource:
self.assertEqual(
variable.update_time,
_rfc3339_to_datetime(resource['updateTime']))
datetime_helpers.DatetimeWithNanoseconds.from_rfc3339(
resource['updateTime']))
else:
self.assertIsNone(variable.update_time)

Expand Down Expand Up @@ -178,6 +179,32 @@ def test_reload_w_alternate_client(self):
self.assertEqual(req['path'], '/%s' % (self.PATH,))
self._verifyResourceProperties(variable, RESOURCE)

def test_with_microseconds(self):
from google.cloud.runtimeconfig.config import Config

resource = {
'updateTime': '2016-04-14T21:21:54.123456Z',
}
conn = _Connection(resource)
client = _Client(project=self.PROJECT, connection=conn)
config = Config(name=self.CONFIG_NAME, client=client)
variable = self._make_one(name=self.VARIABLE_NAME, config=config)
variable.reload(client=client)
self._verifyResourceProperties(variable, resource)

def test_with_nanoseconds(self):
from google.cloud.runtimeconfig.config import Config

resource = {
'updateTime': '2016-04-14T21:21:54.123456789Z',
}
conn = _Connection(resource)
client = _Client(project=self.PROJECT, connection=conn)
config = Config(name=self.CONFIG_NAME, client=client)
variable = self._make_one(name=self.VARIABLE_NAME, config=config)
variable.reload(client=client)
self._verifyResourceProperties(variable, resource)


class _Client(object):

Expand Down