From a93ceb2c4a5af488d2dcf10e1bbd9481563264d5 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Wed, 8 Jun 2016 16:17:48 -0400 Subject: [PATCH] Remove type=timestamp usages This change removes the UNIXEpoch and ISO8601 Format classes from openstack.format as well as all of their usages in Resource classes and their tests. Additionally, this removes the need to depend on oslo.utils and iso8601. Change-Id: I617fb9f0739490a3401f14a654e30b33a476ca59 --- openstack/block_store/v2/snapshot.py | 3 +- openstack/block_store/v2/volume.py | 3 +- openstack/cluster/v1/action.py | 13 +-- openstack/cluster/v1/policy.py | 7 +- openstack/cluster/v1/profile.py | 7 +- openstack/cluster/v1/receiver.py | 8 +- openstack/compute/v2/extension.py | 4 +- openstack/compute/v2/image.py | 7 +- openstack/compute/v2/server.py | 7 +- openstack/format.py | 85 ------------------- openstack/identity/v2/extension.py | 4 +- openstack/identity/v3/trust.py | 4 +- openstack/image/v1/image.py | 7 +- openstack/image/v2/image.py | 7 +- openstack/image/v2/member.py | 7 +- openstack/key_manager/v1/container.py | 7 +- openstack/key_manager/v1/secret.py | 7 +- openstack/metric/v1/resource.py | 10 +-- openstack/network/v2/agent.py | 11 +-- openstack/network/v2/extension.py | 4 +- openstack/network/v2/network.py | 7 +- openstack/network/v2/port.py | 7 +- openstack/network/v2/subnet.py | 7 +- openstack/network/v2/subnet_pool.py | 7 +- openstack/object_store/v1/account.py | 4 +- openstack/object_store/v1/container.py | 4 +- openstack/object_store/v1/obj.py | 10 +-- openstack/orchestration/v1/resource.py | 4 +- openstack/orchestration/v1/stack.py | 7 +- openstack/telemetry/v2/alarm.py | 7 +- openstack/telemetry/v2/alarm_change.py | 4 +- openstack/telemetry/v2/resource.py | 9 +- openstack/telemetry/v2/sample.py | 7 +- openstack/telemetry/v2/statistics.py | 13 +-- .../functional/object_store/v1/test_obj.py | 2 - .../unit/block_store/v2/test_snapshot.py | 5 +- .../tests/unit/block_store/v2/test_volume.py | 5 +- .../tests/unit/cluster/v1/test_action.py | 19 +---- .../tests/unit/cluster/v1/test_policy.py | 10 +-- .../tests/unit/cluster/v1/test_profile.py | 10 +-- .../tests/unit/cluster/v1/test_receiver.py | 10 +-- .../tests/unit/compute/v2/test_extension.py | 5 +- openstack/tests/unit/compute/v2/test_image.py | 9 +- .../tests/unit/compute/v2/test_server.py | 9 +- .../tests/unit/identity/v2/test_extension.py | 6 +- .../tests/unit/identity/v3/test_trust.py | 6 +- openstack/tests/unit/image/v1/test_image.py | 10 +-- openstack/tests/unit/image/v2/test_image.py | 10 +-- openstack/tests/unit/image/v2/test_member.py | 10 +-- .../unit/key_manager/v1/test_container.py | 10 +-- .../tests/unit/key_manager/v1/test_secret.py | 10 +-- .../tests/unit/metric/v1/test_resource.py | 5 +- openstack/tests/unit/network/v2/test_agent.py | 15 +--- .../tests/unit/network/v2/test_extension.py | 6 +- .../tests/unit/network/v2/test_network.py | 10 +-- openstack/tests/unit/network/v2/test_port.py | 10 +-- .../tests/unit/network/v2/test_subnet.py | 10 +-- .../tests/unit/network/v2/test_subnet_pool.py | 10 +-- .../unit/object_store/v1/test_account.py | 7 +- .../unit/object_store/v1/test_container.py | 7 +- .../tests/unit/object_store/v1/test_obj.py | 11 +-- .../unit/orchestration/v1/test_resource.py | 6 +- .../tests/unit/orchestration/v1/test_stack.py | 10 +-- .../tests/unit/telemetry/v2/test_alarm.py | 10 +-- .../unit/telemetry/v2/test_alarm_change.py | 10 +-- .../tests/unit/telemetry/v2/test_resource.py | 12 +-- .../tests/unit/telemetry/v2/test_sample.py | 26 ++---- .../unit/telemetry/v2/test_statistics.py | 18 +--- openstack/tests/unit/test_format.py | 68 --------------- requirements.txt | 2 - 70 files changed, 130 insertions(+), 578 deletions(-) diff --git a/openstack/block_store/v2/snapshot.py b/openstack/block_store/v2/snapshot.py index 4dbf8911..b81f6375 100644 --- a/openstack/block_store/v2/snapshot.py +++ b/openstack/block_store/v2/snapshot.py @@ -39,8 +39,7 @@ class Snapshot(resource.Resource): #: Description of snapshot. Default is None. description = resource.prop("description") #: The timestamp of this snapshot creation. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop("created_at", type=format.ISO8601) + created_at = resource.prop("created_at") #: Metadata associated with this snapshot. metadata = resource.prop("metadata", type=dict) #: The ID of the volume this snapshot was taken of. diff --git a/openstack/block_store/v2/volume.py b/openstack/block_store/v2/volume.py index 194a8255..797d7a60 100644 --- a/openstack/block_store/v2/volume.py +++ b/openstack/block_store/v2/volume.py @@ -68,8 +68,7 @@ class Volume(resource.Resource): #: TODO(briancurtin): This is currently undocumented in the API. attachments = resource.prop("attachments") #: The timestamp of this volume creation. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop("created_at", type=format.ISO8601) + created_at = resource.prop("created_at") class VolumeDetail(Volume): diff --git a/openstack/cluster/v1/action.py b/openstack/cluster/v1/action.py index 1cea89ca..44837f5a 100644 --- a/openstack/cluster/v1/action.py +++ b/openstack/cluster/v1/action.py @@ -12,7 +12,6 @@ from openstack.cluster import cluster_service -from openstack import format from openstack import resource @@ -40,11 +39,9 @@ class Action(resource.Resource): #: Interval in seconds between two consecutive executions. interval = resource.prop('interval') #: The time the action was started. - #: *Type: datetime object parsed from a UNIX epoch* - start_at = resource.prop('start_time', type=format.UNIXEpoch) + start_at = resource.prop('start_time') #: The time the action completed execution. - #: *Type: datetime object parsed from a UNIX epoch* - end_at = resource.prop('end_time', type=format.UNIXEpoch) + end_at = resource.prop('end_time') #: The timeout in seconds. timeout = resource.prop('timeout') #: Current status of the action. @@ -61,8 +58,6 @@ class Action(resource.Resource): #: A list of actions that can start only after this action has finished. depended_by = resource.prop('depended_by', type=list) #: Timestamp when the action is created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: Timestamp when the action was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/cluster/v1/policy.py b/openstack/cluster/v1/policy.py index f301d37e..1d1e5a79 100644 --- a/openstack/cluster/v1/policy.py +++ b/openstack/cluster/v1/policy.py @@ -11,7 +11,6 @@ # under the License. from openstack.cluster import cluster_service -from openstack import format from openstack import resource @@ -36,11 +35,9 @@ class Policy(resource.Resource): #: The type name of the policy. type = resource.prop('type') #: The timestamp when the policy is created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: The timestamp when the policy was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') #: The specification of the policy. spec = resource.prop('spec', type=dict) #: A dictionary containing runtime data of the policy. diff --git a/openstack/cluster/v1/profile.py b/openstack/cluster/v1/profile.py index e7604290..7cdb4488 100644 --- a/openstack/cluster/v1/profile.py +++ b/openstack/cluster/v1/profile.py @@ -11,7 +11,6 @@ # under the License. from openstack.cluster import cluster_service -from openstack import format from openstack import resource @@ -40,8 +39,6 @@ class Profile(resource.Resource): #: A collection of key-value pairs that are attached to the profile. metadata = resource.prop('metadata', type=dict) #: Timestamp of when the profile was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: Timestamp of when the profile was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/cluster/v1/receiver.py b/openstack/cluster/v1/receiver.py index a55716c5..7383842a 100644 --- a/openstack/cluster/v1/receiver.py +++ b/openstack/cluster/v1/receiver.py @@ -10,9 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. - from openstack.cluster import cluster_service -from openstack import format from openstack import resource @@ -44,11 +42,9 @@ class Receiver(resource.Resource): #: The name of the targeted action. action = resource.prop('action') #: Timestamp of when the receiver was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: Timestamp of when the receiver was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') #: The credential of the impersonated user. actor = resource.prop('actor', type=dict) #: A dictionary containing key-value pairs that are provided to the diff --git a/openstack/compute/v2/extension.py b/openstack/compute/v2/extension.py index 287490a5..79c7e085 100644 --- a/openstack/compute/v2/extension.py +++ b/openstack/compute/v2/extension.py @@ -11,7 +11,6 @@ # under the License. from openstack.compute import compute_service -from openstack import format from openstack import resource @@ -39,5 +38,4 @@ class Extension(resource.Resource): #: A URL pointing to the namespace for this extension. namespace = resource.prop('namespace') #: Timestamp when this extension was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') diff --git a/openstack/compute/v2/image.py b/openstack/compute/v2/image.py index 5bd5fc7e..704455e9 100644 --- a/openstack/compute/v2/image.py +++ b/openstack/compute/v2/image.py @@ -12,7 +12,6 @@ from openstack.compute import compute_service from openstack.compute.v2 import metadata -from openstack import format from openstack import resource @@ -34,8 +33,7 @@ class Image(resource.Resource, metadata.MetadataMixin): #: The name of this image. name = resource.prop('name') #: Timestamp when the image was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created', type=format.ISO8601) + created_at = resource.prop('created') #: Metadata pertaining to this image. *Type: dict* metadata = resource.prop('metadata', type=dict) #: The mimimum disk size. *Type: int* @@ -48,8 +46,7 @@ class Image(resource.Resource, metadata.MetadataMixin): #: The status of this image. status = resource.prop('status') #: Timestamp when the image was updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') #: Size of the image in bytes. *Type: int* size = resource.prop('OS-EXT-IMG-SIZE:size', type=int) diff --git a/openstack/compute/v2/server.py b/openstack/compute/v2/server.py index c0d71355..5aecc839 100644 --- a/openstack/compute/v2/server.py +++ b/openstack/compute/v2/server.py @@ -12,7 +12,6 @@ from openstack.compute import compute_service from openstack.compute.v2 import metadata -from openstack import format from openstack import resource from openstack import utils @@ -41,8 +40,7 @@ class Server(resource.Resource, metadata.MetadataMixin): #: of the IP address. *Type: dict* addresses = resource.prop('addresses', type=dict) #: Timestamp of when the server was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created', type=format.ISO8601) + created_at = resource.prop('created') #: The flavor reference, as a ID or full URL, for the flavor to use for #: this server. flavor_id = resource.prop('flavorRef') @@ -69,8 +67,7 @@ class Server(resource.Resource, metadata.MetadataMixin): #: ``SUSPENDED``, ``UNKNOWN``, or ``VERIFY_RESIZE``. status = resource.prop('status') #: Timestamp of when this server was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') #: The user ID associated with this server. user_id = resource.prop('user_id') diff --git a/openstack/format.py b/openstack/format.py index 9b3ef3d5..94fd310f 100644 --- a/openstack/format.py +++ b/openstack/format.py @@ -10,15 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from datetime import datetime -import numbers -import time - -from iso8601 import iso8601 -import six - -from oslo_utils import timeutils - class Formatter(object): @@ -33,82 +24,6 @@ class Formatter(object): raise NotImplementedError -class ISO8601(Formatter): - - @classmethod - def serialize(cls, value): - """Convert a datetime to an ISO8601 string""" - if isinstance(value, datetime): - return value.isoformat() - elif isinstance(value, six.string_types): - # If we're already given a string, keep it as-is. - # This happens when a string comes back in a response body, - # as opposed to the datetime case above which happens when - # a user is setting a datetime for a request. - return value - else: - raise ValueError("Unable to serialize ISO8601: %s" % value) - - @classmethod - def deserialize(cls, value): - """Convert an ISO8601 string to a datetime object""" - if isinstance(value, six.string_types): - return timeutils.parse_isotime(value) - else: - raise ValueError("Unable to deserialize ISO8601: %s" % value) - - -class UNIXEpoch(Formatter): - - EPOCH = datetime(1970, 1, 1, tzinfo=iso8601.UTC) - - @classmethod - def serialize(cls, value): - """Convert a datetime to a UNIX epoch""" - if isinstance(value, datetime): - # Do not try to format using %s as it's platform dependent. - return (value - cls.EPOCH).total_seconds() - elif isinstance(value, numbers.Number): - return value - else: - raise ValueError("Unable to serialize UNIX epoch: %s" % value) - - @classmethod - def deserialize(cls, value): - """Convert a UNIX epoch into a datetime object""" - try: - value = float(value) - except ValueError: - raise ValueError("Unable to deserialize UNIX epoch: %s" % value) - - # gmtime doesn't respect microseconds so we need to parse them out - # if they're there and build the datetime appropriately with the - # proper precision. - # NOTES: - # 1. datetime.fromtimestamp sort of solves this but using localtime - # instead of UTC, which we need. - # 2. On Python 2 we can't just str(value) as it truncates digits - # that are significant to us. - parsed_value = "%000000f" % value - decimal = parsed_value.find(".") - - if decimal == -1: - microsecond = 0 - else: - # Some examples of these timestamps include less precision - # than the allowable 6 digits that can represent microseconds, - # so since we have a string we need to construct a real - # count of microseconds instead of just converting the - # stringified amount to an int. - fractional_second = float(parsed_value[decimal:]) * 1e6 - microsecond = int(fractional_second) - - gmt = time.gmtime(value) - - return datetime(*gmt[:6], microsecond=microsecond, - tzinfo=iso8601.UTC) - - class BoolStr(Formatter): @classmethod diff --git a/openstack/identity/v2/extension.py b/openstack/identity/v2/extension.py index 77fc4079..19c8ab44 100644 --- a/openstack/identity/v2/extension.py +++ b/openstack/identity/v2/extension.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.identity import identity_service from openstack import resource @@ -42,8 +41,7 @@ class Extension(resource.Resource): #: *Type: string* namespace = resource.prop('namespace') #: The last time the extension has been modified (update date). - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') @classmethod def list(cls, session, **params): diff --git a/openstack/identity/v3/trust.py b/openstack/identity/v3/trust.py index 750b37f1..3c697bd7 100644 --- a/openstack/identity/v3/trust.py +++ b/openstack/identity/v3/trust.py @@ -11,7 +11,6 @@ # under the License. -from openstack import format from openstack.identity import identity_service from openstack import resource @@ -35,8 +34,7 @@ class Trust(resource.Resource): #: Specifies the expiration time of the trust. A trust may be revoked #: ahead of expiration. If the value represents a time in the past, #: the trust is deactivated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - expires_at = resource.prop('expires_at', type=format.ISO8601) + expires_at = resource.prop('expires_at') #: ID of the trust object. *Type: string* id = resource.prop('id') #: If ``impersonation`` is set to true, then the ``user`` attribute diff --git a/openstack/image/v1/image.py b/openstack/image/v1/image.py index 36cf3137..bbe0f55d 100644 --- a/openstack/image/v1/image.py +++ b/openstack/image/v1/image.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.image import image_service from openstack import resource @@ -40,8 +39,7 @@ class Image(resource.Resource): #: A URL to copy an image from copy_from = resource.prop('copy_from') #: The timestamp when this image was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk. #: The disk format of a VM image is the format of the underlying #: disk image. Virtual appliance vendors have different formats for @@ -72,5 +70,4 @@ class Image(resource.Resource): #: The image status. status = resource.prop('status') #: The timestamp when this image was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/image/v2/image.py b/openstack/image/v2/image.py index 6fb68c47..f7028f99 100644 --- a/openstack/image/v2/image.py +++ b/openstack/image/v2/image.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.image import image_service from openstack import resource from openstack import utils @@ -44,8 +43,7 @@ class Image(resource.Resource): #: the image is just a blob of unstructured data. container_format = resource.prop('container_format') #: The date and time when the image was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk. #: The disk format of a VM image is the format of the underlying #: disk image. Virtual appliance vendors have different formats @@ -75,8 +73,7 @@ class Image(resource.Resource): #: Tags, if any, that are associated with the image. tags = resource.prop('tags') #: The date and time when the image was updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') #: The virtual size of the image. virtual_size = resource.prop('virtual_size') #: The image visibility. diff --git a/openstack/image/v2/member.py b/openstack/image/v2/member.py index fa41a3f3..c2529154 100644 --- a/openstack/image/v2/member.py +++ b/openstack/image/v2/member.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.image import image_service from openstack import resource @@ -30,12 +29,10 @@ class Member(resource.Resource): # Properties #: The date and time when the member was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: Image ID stored through the image API. Typically a UUID. image_id = resource.prop('image_id') #: The status of the image. status = resource.prop('status') #: The date and time when the member was updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/key_manager/v1/container.py b/openstack/key_manager/v1/container.py index 4d83447f..a11074bf 100644 --- a/openstack/key_manager/v1/container.py +++ b/openstack/key_manager/v1/container.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.key_manager import key_manager_service from openstack import resource @@ -32,8 +31,7 @@ class Container(resource.Resource): #: A URI for this container container_ref = resource.prop('container_ref') #: The timestamp when this container was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created', type=format.ISO8601) + created_at = resource.prop('created') #: The name of this container name = resource.prop('name') #: A list of references to secrets in this container @@ -43,5 +41,4 @@ class Container(resource.Resource): #: The type of this container type = resource.prop('type') #: The timestamp when this container was updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') diff --git a/openstack/key_manager/v1/secret.py b/openstack/key_manager/v1/secret.py index c7a5392c..2d8a5685 100644 --- a/openstack/key_manager/v1/secret.py +++ b/openstack/key_manager/v1/secret.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.key_manager import key_manager_service from openstack import resource @@ -37,8 +36,7 @@ class Secret(resource.Resource): #: A list of content types content_types = resource.prop('content_types') #: Once this timestamp has past, the secret will no longer be available. - #: *Type: datetime object parsed from ISO 8601 formatted string* - expires_at = resource.prop('expiration', type=format.ISO8601) + expires_at = resource.prop('expiration') #: The type/mode of the algorithm associated with the secret information. mode = resource.prop('mode') #: The name of the secret set by the user @@ -48,5 +46,4 @@ class Secret(resource.Resource): #: The status of this secret status = resource.prop('status') #: A timestamp when this secret was updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') diff --git a/openstack/metric/v1/resource.py b/openstack/metric/v1/resource.py index 13dc49eb..f6f8c842 100644 --- a/openstack/metric/v1/resource.py +++ b/openstack/metric/v1/resource.py @@ -9,7 +9,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from openstack import format + from openstack.metric import metric_service from openstack import resource @@ -37,13 +37,9 @@ class Generic(resource.Resource): #: The ID of the project project_id = resource.prop('project_id') #: Timestamp when this resource was started - #: *Type: datetime object parsed from ISO 8601 formatted string* - started_at = resource.prop('started_at', - type=format.ISO8601) + started_at = resource.prop('started_at') #: Timestamp when this resource was ended - #: *Type: datetime object parsed from ISO 8601 formatted string* - ended_at = resource.prop('ended_at', - type=format.ISO8601) + ended_at = resource.prop('ended_at') #: A dictionary of metrics collected on this resource metrics = resource.prop('metrics', type=dict) diff --git a/openstack/network/v2/agent.py b/openstack/network/v2/agent.py index 95ade0ca..9197e9ee 100644 --- a/openstack/network/v2/agent.py +++ b/openstack/network/v2/agent.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.network import network_service from openstack import resource @@ -38,14 +37,11 @@ class Agent(resource.Resource): #: Network agent configuration data specific to the agent_type. configuration = resource.prop('configurations') #: Timestamp when the network agent was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: The network agent description. description = resource.prop('description') #: Timestamp when the network agent's heartbeat was last seen. - #: *Type: datetime object parsed from ISO 8601 formatted string* - last_heartbeat_at = resource.prop('heartbeat_timestamp', - type=format.ISO8601) + last_heartbeat_at = resource.prop('heartbeat_timestamp') #: The host the agent is running on. host = resource.prop('host') #: The administrative state of the network agent, which is up @@ -55,7 +51,6 @@ class Agent(resource.Resource): #: *Type: bool* is_alive = resource.prop('alive', type=bool) #: Timestamp when the network agent was last started. - #: *Type: datetime object parsed from ISO 8601 formatted string* - started_at = resource.prop('started_at', type=format.ISO8601) + started_at = resource.prop('started_at') #: The messaging queue topic the network agent subscribes to. topic = resource.prop('topic') diff --git a/openstack/network/v2/extension.py b/openstack/network/v2/extension.py index 215634fd..8096213f 100644 --- a/openstack/network/v2/extension.py +++ b/openstack/network/v2/extension.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.network import network_service from openstack import resource @@ -38,5 +37,4 @@ class Extension(resource.Resource): #: A URL pointing to the namespace for this extension. namespace = resource.prop('namespace') #: Timestamp when the extension was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated', type=format.ISO8601) + updated_at = resource.prop('updated') diff --git a/openstack/network/v2/network.py b/openstack/network/v2/network.py index b24170a9..be9ff816 100644 --- a/openstack/network/v2/network.py +++ b/openstack/network/v2/network.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.network import network_service from openstack import resource @@ -36,8 +35,7 @@ class Network(resource.Resource): #: *Type: list of availability zone names* availability_zones = resource.prop('availability_zones') #: Timestamp when the network was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: The network description. description = resource.prop('description') #: The ID of the IPv4 address scope for the network. @@ -85,5 +83,4 @@ class Network(resource.Resource): #: *Type: list of strs of the subnet IDs* subnet_ids = resource.prop('subnets', type=list) #: Timestamp when the network was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/network/v2/port.py b/openstack/network/v2/port.py index 44320b78..788e3c3f 100644 --- a/openstack/network/v2/port.py +++ b/openstack/network/v2/port.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.network import network_service from openstack import resource @@ -58,8 +57,7 @@ class Port(resource.Resource): #: visible to only port owners and administrative users. binding_vnic_type = resource.prop('binding:vnic_type') #: Timestamp when the port was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: The port description. description = resource.prop('description') #: Device ID of this port. @@ -97,5 +95,4 @@ class Port(resource.Resource): #: The port status. Value is ``ACTIVE`` or ``DOWN``. status = resource.prop('status') #: Timestamp when the port was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/network/v2/subnet.py b/openstack/network/v2/subnet.py index ac3f2c9b..5f6a330c 100644 --- a/openstack/network/v2/subnet.py +++ b/openstack/network/v2/subnet.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.network import network_service from openstack import resource @@ -34,8 +33,7 @@ class Subnet(resource.Resource): #: The CIDR. cidr = resource.prop('cidr') #: Timestamp when the subnet was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: The subnet description. description = resource.prop('description') #: A list of DNS nameservers. @@ -63,5 +61,4 @@ class Subnet(resource.Resource): #: The subnet pool ID from which to obtain a CIDR. subnet_pool_id = resource.prop('subnetpool_id') #: Timestamp when the subnet was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/network/v2/subnet_pool.py b/openstack/network/v2/subnet_pool.py index 4477ad98..e25e51ae 100644 --- a/openstack/network/v2/subnet_pool.py +++ b/openstack/network/v2/subnet_pool.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.network import network_service from openstack import resource @@ -32,8 +31,7 @@ class SubnetPool(resource.Resource): #: The ID of the address scope associated with the subnet pool. address_scope_id = resource.prop('address_scope_id') #: Timestamp when the subnet pool was created. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('created_at', type=format.ISO8601) + created_at = resource.prop('created_at') #: The length of the prefix to allocate when the cidr or prefixlen #: attributes are omitted when creating a subnet. *Type: int* default_prefix_length = resource.prop('default_prefixlen', type=int) @@ -69,5 +67,4 @@ class SubnetPool(resource.Resource): #: *Type: list* prefixes = resource.prop('prefixes', type=list) #: Timestamp when the subnet pool was last updated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_at', type=format.ISO8601) + updated_at = resource.prop('updated_at') diff --git a/openstack/object_store/v1/account.py b/openstack/object_store/v1/account.py index a82e6e61..8857882d 100644 --- a/openstack/object_store/v1/account.py +++ b/openstack/object_store/v1/account.py @@ -11,7 +11,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.object_store.v1 import _base from openstack import resource @@ -40,5 +39,4 @@ class Account(_base.BaseResource): #: this header is not returned by this operation. meta_temp_url_key_2 = resource.header("x-account-meta-temp-url-key-2") #: The timestamp of the transaction. - #: *Type: datetime object parsed from a UNIX epoch* - timestamp = resource.header("x-timestamp", type=format.UNIXEpoch) + timestamp = resource.header("x-timestamp") diff --git a/openstack/object_store/v1/container.py b/openstack/object_store/v1/container.py index 58e0dae7..678846d6 100644 --- a/openstack/object_store/v1/container.py +++ b/openstack/object_store/v1/container.py @@ -11,7 +11,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.object_store.v1 import _base from openstack import resource @@ -53,8 +52,7 @@ class Container(_base.BaseResource): #: The count of bytes used in total. bytes_used = resource.header("x-container-bytes-used", type=int) #: The timestamp of the transaction. - #: *Type: datetime object parsed from a UNIX epoch* - timestamp = resource.header("x-timestamp", type=format.UNIXEpoch) + timestamp = resource.header("x-timestamp") # Request headers (when id=None) #: If set to True, Object Storage queries all replicas to return the diff --git a/openstack/object_store/v1/obj.py b/openstack/object_store/v1/obj.py index fea1eec3..1b93e8e8 100644 --- a/openstack/object_store/v1/obj.py +++ b/openstack/object_store/v1/obj.py @@ -13,7 +13,6 @@ import copy -from openstack import format from openstack.object_store import object_store_service from openstack.object_store.v1 import _base from openstack import resource @@ -82,8 +81,7 @@ class Object(_base.BaseResource): #: Used with temporary URLs to specify the expiry time of the #: signature. For more information about temporary URLs, see #: OpenStack Object Storage API v1 Reference. - #: *Type: datetime object parsed from ISO 8601 formatted string* - expires_at = resource.header("expires", type=format.ISO8601) + expires_at = resource.header("expires") #: If you include the multipart-manifest=get query parameter and #: the object is a large object, the object contents are not #: returned. Instead, the manifest is returned in the @@ -133,15 +131,13 @@ class Object(_base.BaseResource): #: If set, the time when the object will be deleted by the system #: in the format of a UNIX Epoch timestamp. #: If not set, this header is not returned by this operation. - #: *Type: datetime object parsed from a UNIX epoch* - delete_at = resource.header("x-delete-at", type=format.UNIXEpoch) + delete_at = resource.header("x-delete-at") #: If set, to this is a dynamic large object manifest object. #: The value is the container and object name prefix of the #: segment objects in the form container/prefix. object_manifest = resource.header("x-object-manifest") #: The timestamp of the transaction. - #: *Type: datetime object parsed from a UNIX epoch* - timestamp = resource.header("x-timestamp", type=format.UNIXEpoch) + timestamp = resource.header("x-timestamp") #: The date and time that the object was created or the last #: time that the metadata was changed. last_modified_at = resource.header("last_modified", alias="last-modified") diff --git a/openstack/orchestration/v1/resource.py b/openstack/orchestration/v1/resource.py index 4d86fa8d..6e7c08f3 100644 --- a/openstack/orchestration/v1/resource.py +++ b/openstack/orchestration/v1/resource.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack.orchestration import orchestration_service from openstack import resource @@ -52,5 +51,4 @@ class Resource(resource.Resource): #: A string that explains why the resource is in its current status. status_reason = resource.prop('resource_status_reason') #: Timestamp of the last update made to the resource. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_time', type=format.ISO8601) + updated_at = resource.prop('updated_time') diff --git a/openstack/orchestration/v1/stack.py b/openstack/orchestration/v1/stack.py index 0bf45189..ab05d355 100644 --- a/openstack/orchestration/v1/stack.py +++ b/openstack/orchestration/v1/stack.py @@ -11,7 +11,6 @@ # under the License. from openstack import exceptions -from openstack import format from openstack.orchestration import orchestration_service from openstack import resource from openstack import utils @@ -37,8 +36,7 @@ class Stack(resource.Resource): #: required by the stack. capabilities = resource.prop('capabilities') #: Timestamp of the stack creation. - #: *Type: datetime object parsed from ISO 8601 formatted string* - created_at = resource.prop('creation_time', type=format.ISO8601) + created_at = resource.prop('creation_time') #: A text description of the stack. description = resource.prop('description') #: Whether the stack will support a rollback operation on stack @@ -67,8 +65,7 @@ class Stack(resource.Resource): #: Stack operation timeout in minutes. timeout_mins = resource.prop('timeout_mins') #: Timestamp of last update on the stack. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('updated_time', type=format.ISO8601) + updated_at = resource.prop('updated_time') def _action(self, session, body): """Perform stack actions""" diff --git a/openstack/telemetry/v2/alarm.py b/openstack/telemetry/v2/alarm.py index 1d182016..25364716 100644 --- a/openstack/telemetry/v2/alarm.py +++ b/openstack/telemetry/v2/alarm.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack import resource from openstack.telemetry import telemetry_service from openstack import utils @@ -56,8 +55,7 @@ class Alarm(resource.Resource): #: The state off the alarm state = resource.prop('state') #: The timestamp of the last alarm state change. - #: *Type: datetime object parsed from ISO 8601 formatted string* - state_changed_at = resource.prop('state_timestamp', type=format.ISO8601) + state_changed_at = resource.prop('state_timestamp') # TODO(briancurtin): undocumented threshold_rule = resource.prop('threshold_rule', type=dict) #: Describe time constraints for the alarm @@ -65,8 +63,7 @@ class Alarm(resource.Resource): #: Explicit type specifier to select which rule to follow type = resource.prop('type') #: The timestamp of the last alarm definition update. - #: *Type: datetime object parsed from ISO 8601 formatted string* - updated_at = resource.prop('timestamp', type=format.ISO8601) + updated_at = resource.prop('timestamp') #: The ID of the user who created the alarm user_id = resource.prop('user_id') diff --git a/openstack/telemetry/v2/alarm_change.py b/openstack/telemetry/v2/alarm_change.py index d959fab0..42a56171 100644 --- a/openstack/telemetry/v2/alarm_change.py +++ b/openstack/telemetry/v2/alarm_change.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack import resource from openstack.telemetry import telemetry_service @@ -37,8 +36,7 @@ class AlarmChange(resource.Resource): #: The project ID of the initiating identity project_id = resource.prop('project_id') #: The time/date of the alarm change. - #: *Type: datetime object parsed from ISO 8601 formatted string* - triggered_at = resource.prop('timestamp', type=format.ISO8601) + triggered_at = resource.prop('timestamp') #: The type of change type = resource.prop('type') #: The user ID of the initiating identity diff --git a/openstack/telemetry/v2/resource.py b/openstack/telemetry/v2/resource.py index fe315660..ed82fbb2 100644 --- a/openstack/telemetry/v2/resource.py +++ b/openstack/telemetry/v2/resource.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack import resource from openstack.telemetry import telemetry_service @@ -28,14 +27,10 @@ class Resource(resource.Resource): # Properties #: UTC date & time not later than the first sample known #: for this resource. - #: *Type: datetime object parsed from ISO 8601 formatted string* - first_sample_at = resource.prop('first_sample_timestamp', - type=format.ISO8601) + first_sample_at = resource.prop('first_sample_timestamp') #: UTC date & time not earlier than the last sample known #: for this resource. - #: *Type: datetime object parsed from ISO 8601 formatted string* - last_sample_at = resource.prop('last_sample_timestamp', - type=format.ISO8601) + last_sample_at = resource.prop('last_sample_timestamp') #: A list containing a self link and associated meter links links = resource.prop('links') #: Arbitrary metadata associated with the resource diff --git a/openstack/telemetry/v2/sample.py b/openstack/telemetry/v2/sample.py index e6f0d114..7da4443e 100644 --- a/openstack/telemetry/v2/sample.py +++ b/openstack/telemetry/v2/sample.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack import resource from openstack.telemetry import telemetry_service @@ -29,15 +28,13 @@ class Sample(resource.Resource): #: The meter name this sample is for counter_name = resource.prop('meter', alias='counter_name') #: When the sample has been generated. - #: *Type: datetime object parsed from ISO 8601 formatted string* - generated_at = resource.prop('timestamp', type=format.ISO8601) + generated_at = resource.prop('timestamp') #: Arbitrary metadata associated with the sample metadata = resource.prop('metadata', alias='resource_metadata') #: The ID of the project this sample was taken for project_id = resource.prop('project_id') #: When the sample has been recorded. - #: *Type: datetime object parsed from ISO 8601 formatted string* - recorded_at = resource.prop('recorded_at', type=format.ISO8601) + recorded_at = resource.prop('recorded_at') #: The ID of the resource this sample was taken for resource_id = resource.prop('resource_id') #: The name of the source that identifies where the sample comes from diff --git a/openstack/telemetry/v2/statistics.py b/openstack/telemetry/v2/statistics.py index 4a6d3cd2..88a1613c 100644 --- a/openstack/telemetry/v2/statistics.py +++ b/openstack/telemetry/v2/statistics.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack import format from openstack import resource from openstack.telemetry import telemetry_service @@ -38,11 +37,9 @@ class Statistics(resource.Resource): #: The difference, in seconds, between the oldest and newest timestamp duration = resource.prop('duration') #: UTC date and time of the oldest timestamp, or the query end time. - #: *Type: datetime object parsed from ISO 8601 formatted string* - duration_end_at = resource.prop('duration_end', type=format.ISO8601) + duration_end_at = resource.prop('duration_end') #: UTC date and time of the earliest timestamp, or the query start time. - #: *Type: datetime object parsed from ISO 8601 formatted string* - duration_start_at = resource.prop('duration_start', type=format.ISO8601) + duration_start_at = resource.prop('duration_start') #: Dictionary of field names for group, if groupby statistics are requested group_by = resource.prop('groupby') #: The maximum volume seen in the data @@ -52,11 +49,9 @@ class Statistics(resource.Resource): #: The difference, in seconds, between the period start and end period = resource.prop('period') #: UTC date and time of the period end. - #: *Type: datetime object parsed from ISO 8601 formatted string* - period_end_at = resource.prop('period_end', type=format.ISO8601) + period_end_at = resource.prop('period_end') #: UTC date and time of the period start. - #: *Type: datetime object parsed from ISO 8601 formatted string* - period_start_at = resource.prop('period_start', type=format.ISO8601) + period_start_at = resource.prop('period_start') #: The total of all of the volume values seen in the data sum = resource.prop('sum') #: The unit type of the data set diff --git a/openstack/tests/functional/object_store/v1/test_obj.py b/openstack/tests/functional/object_store/v1/test_obj.py index 5de3f658..a96a18ee 100644 --- a/openstack/tests/functional/object_store/v1/test_obj.py +++ b/openstack/tests/functional/object_store/v1/test_obj.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime import uuid from openstack.tests.functional import base @@ -80,7 +79,6 @@ class TestObject(base.BaseFunctionalTest): self.assertEqual('v0', obj.metadata['k0']) self.assertEqual('attachment', obj.content_disposition) self.assertEqual('deflate', obj.content_encoding) - self.assertIsInstance(obj.delete_at, datetime.datetime) # unset system metadata self.conn.object_store.delete_object_metadata( diff --git a/openstack/tests/unit/block_store/v2/test_snapshot.py b/openstack/tests/unit/block_store/v2/test_snapshot.py index 69f15589..55f40e51 100644 --- a/openstack/tests/unit/block_store/v2/test_snapshot.py +++ b/openstack/tests/unit/block_store/v2/test_snapshot.py @@ -9,7 +9,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import datetime import testtools @@ -58,9 +57,7 @@ class TestSnapshot(testtools.TestCase): sot = snapshot.Snapshot(SNAPSHOT) self.assertEqual(SNAPSHOT["id"], sot.id) self.assertEqual(SNAPSHOT["status"], sot.status) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(SNAPSHOT["created_at"], sot.created_at) self.assertEqual(SNAPSHOT["metadata"], sot.metadata) self.assertEqual(SNAPSHOT["volume_id"], sot.volume_id) self.assertEqual(SNAPSHOT["size"], sot.size) diff --git a/openstack/tests/unit/block_store/v2/test_volume.py b/openstack/tests/unit/block_store/v2/test_volume.py index 5850e0b2..52b5e1ec 100644 --- a/openstack/tests/unit/block_store/v2/test_volume.py +++ b/openstack/tests/unit/block_store/v2/test_volume.py @@ -11,7 +11,6 @@ # under the License. import copy -import datetime import testtools @@ -74,9 +73,7 @@ class TestVolume(testtools.TestCase): self.assertEqual(VOLUME["attachments"], sot.attachments) self.assertEqual(VOLUME["availability_zone"], sot.availability_zone) self.assertFalse(sot.is_bootable) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(VOLUME["created_at"], sot.created_at) self.assertEqual(VOLUME["description"], sot.description) self.assertEqual(VOLUME["volume_type"], sot.volume_type) self.assertEqual(VOLUME["snapshot_id"], sot.snapshot_id) diff --git a/openstack/tests/unit/cluster/v1/test_action.py b/openstack/tests/unit/cluster/v1/test_action.py index e96fb464..c9f7a88a 100644 --- a/openstack/tests/unit/cluster/v1/test_action.py +++ b/openstack/tests/unit/cluster/v1/test_action.py @@ -10,9 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime -import iso8601 - import testtools from openstack.cluster.v1 import action @@ -65,12 +62,8 @@ class TestAction(testtools.TestCase): self.assertEqual(FAKE['cause'], sot.cause) self.assertEqual(FAKE['owner'], sot.owner_id) self.assertEqual(FAKE['interval'], sot.interval) - self.assertEqual(datetime.datetime(2016, 1, 21, 22, 7, 35, 486720, - tzinfo=iso8601.UTC), - sot.start_at) - self.assertEqual(datetime.datetime(2016, 1, 21, 22, 7, 35, 486720, - tzinfo=iso8601.UTC), - sot.end_at) + self.assertEqual(FAKE['start_time'], sot.start_at) + self.assertEqual(FAKE['end_time'], sot.end_at) self.assertEqual(FAKE['timeout'], sot.timeout) self.assertEqual(FAKE['status'], sot.status) self.assertEqual(FAKE['status_reason'], sot.status_reason) @@ -78,9 +71,5 @@ class TestAction(testtools.TestCase): self.assertEqual(FAKE['outputs'], sot.outputs) self.assertEqual(FAKE['depends_on'], sot.depends_on) self.assertEqual(FAKE['depended_by'], sot.depended_by) - dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(FAKE['created_at'], sot.created_at) + self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/cluster/v1/test_policy.py b/openstack/tests/unit/cluster/v1/test_policy.py index 966e7e3a..a589f48b 100644 --- a/openstack/tests/unit/cluster/v1/test_policy.py +++ b/openstack/tests/unit/cluster/v1/test_policy.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.cluster.v1 import policy @@ -62,9 +60,5 @@ class TestPolicy(testtools.TestCase): self.assertEqual(FAKE['name'], sot.name) self.assertEqual(FAKE['spec'], sot.spec) self.assertEqual(FAKE['data'], sot.data) - dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(FAKE['created_at'], sot.created_at) + self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/cluster/v1/test_profile.py b/openstack/tests/unit/cluster/v1/test_profile.py index 3570f783..bab0c993 100644 --- a/openstack/tests/unit/cluster/v1/test_profile.py +++ b/openstack/tests/unit/cluster/v1/test_profile.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.cluster.v1 import profile @@ -65,9 +63,5 @@ class TestProfile(testtools.TestCase): self.assertEqual(FAKE['metadata'], sot.metadata) self.assertEqual(FAKE['spec'], sot.spec) self.assertEqual(FAKE['type'], sot.type_name) - dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(FAKE['created_at'], sot.created_at) + self.assertEqual(FAKE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/cluster/v1/test_receiver.py b/openstack/tests/unit/cluster/v1/test_receiver.py index 1da31ac4..585500d2 100644 --- a/openstack/tests/unit/cluster/v1/test_receiver.py +++ b/openstack/tests/unit/cluster/v1/test_receiver.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.cluster.v1 import receiver @@ -66,12 +64,8 @@ class TestReceiver(testtools.TestCase): self.assertEqual(FAKE['cluster_id'], sot.cluster_id) self.assertEqual(FAKE['action'], sot.action) self.assertEqual(FAKE['params'], sot.params) - dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(FAKE['created_at'], sot.created_at) + self.assertEqual(FAKE['updated_at'], sot.updated_at) self.assertEqual(FAKE['user'], sot.user_id) self.assertEqual(FAKE['project'], sot.project_id) self.assertEqual(FAKE['domain'], sot.domain_id) diff --git a/openstack/tests/unit/compute/v2/test_extension.py b/openstack/tests/unit/compute/v2/test_extension.py index 43b33041..e94ca6fb 100644 --- a/openstack/tests/unit/compute/v2/test_extension.py +++ b/openstack/tests/unit/compute/v2/test_extension.py @@ -9,7 +9,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import datetime import testtools @@ -48,6 +47,4 @@ class TestExtension(testtools.TestCase): self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['namespace'], sot.namespace) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated'], sot.updated_at) diff --git a/openstack/tests/unit/compute/v2/test_image.py b/openstack/tests/unit/compute/v2/test_image.py index e9683436..9015e03c 100644 --- a/openstack/tests/unit/compute/v2/test_image.py +++ b/openstack/tests/unit/compute/v2/test_image.py @@ -9,7 +9,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import datetime import testtools @@ -71,9 +70,7 @@ class TestImage(testtools.TestCase): def test_make_detail(self): sot = image.ImageDetail(DETAIL_EXAMPLE) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(DETAIL_EXAMPLE['created'], sot.created_at) self.assertEqual(DETAIL_EXAMPLE['id'], sot.id) self.assertEqual(DETAIL_EXAMPLE['links'], sot.links) self.assertEqual(DETAIL_EXAMPLE['metadata'], sot.metadata) @@ -82,7 +79,5 @@ class TestImage(testtools.TestCase): self.assertEqual(DETAIL_EXAMPLE['name'], sot.name) self.assertEqual(DETAIL_EXAMPLE['progress'], sot.progress) self.assertEqual(DETAIL_EXAMPLE['status'], sot.status) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(DETAIL_EXAMPLE['updated'], sot.updated_at) self.assertEqual(DETAIL_EXAMPLE['OS-EXT-IMG-SIZE:size'], sot.size) diff --git a/openstack/tests/unit/compute/v2/test_server.py b/openstack/tests/unit/compute/v2/test_server.py index 26e48304..1e663a46 100644 --- a/openstack/tests/unit/compute/v2/test_server.py +++ b/openstack/tests/unit/compute/v2/test_server.py @@ -11,7 +11,6 @@ # under the License. import copy -import datetime import mock import testtools @@ -66,9 +65,7 @@ class TestServer(testtools.TestCase): self.assertEqual(EXAMPLE['accessIPv4'], sot.access_ipv4) self.assertEqual(EXAMPLE['accessIPv6'], sot.access_ipv6) self.assertEqual(EXAMPLE['addresses'], sot.addresses) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created'], sot.created_at) self.assertEqual(EXAMPLE['flavorRef'], sot.flavor_id) self.assertEqual(EXAMPLE['hostId'], sot.host_id) self.assertEqual(EXAMPLE['id'], sot.id) @@ -79,9 +76,7 @@ class TestServer(testtools.TestCase): self.assertEqual(EXAMPLE['progress'], sot.progress) self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) self.assertEqual(EXAMPLE['status'], sot.status) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated'], sot.updated_at) self.assertEqual(EXAMPLE['user_id'], sot.user_id) def test_detail(self): diff --git a/openstack/tests/unit/identity/v2/test_extension.py b/openstack/tests/unit/identity/v2/test_extension.py index 1eceba81..3c9471d5 100644 --- a/openstack/tests/unit/identity/v2/test_extension.py +++ b/openstack/tests/unit/identity/v2/test_extension.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import testtools @@ -49,9 +47,7 @@ class TestExtension(testtools.TestCase): self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['namespace'], sot.namespace) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated'], sot.updated_at) def test_list(self): resp = mock.Mock() diff --git a/openstack/tests/unit/identity/v3/test_trust.py b/openstack/tests/unit/identity/v3/test_trust.py index cafe41fb..93d1d899 100644 --- a/openstack/tests/unit/identity/v3/test_trust.py +++ b/openstack/tests/unit/identity/v3/test_trust.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.identity.v3 import trust @@ -46,9 +44,7 @@ class TestTrust(testtools.TestCase): sot = trust.Trust(EXAMPLE) self.assertEqual(EXAMPLE['project_id'], sot.project_id) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.expires_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['expires_at'], sot.expires_at) self.assertEqual(EXAMPLE['id'], sot.id) self.assertTrue(sot.is_impersonation) self.assertEqual(EXAMPLE['trustee_user_id'], sot.trustee_user_id) diff --git a/openstack/tests/unit/image/v1/test_image.py b/openstack/tests/unit/image/v1/test_image.py index 29004605..a9fb3325 100644 --- a/openstack/tests/unit/image/v1/test_image.py +++ b/openstack/tests/unit/image/v1/test_image.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.image.v1 import image @@ -69,9 +67,5 @@ class TestImage(testtools.TestCase): self.assertTrue(sot.is_protected) self.assertEqual(EXAMPLE['size'], sot.size) self.assertEqual(EXAMPLE['status'], sot.status) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/image/v2/test_image.py b/openstack/tests/unit/image/v2/test_image.py index cd3fcd62..a0b8d1d7 100644 --- a/openstack/tests/unit/image/v2/test_image.py +++ b/openstack/tests/unit/image/v2/test_image.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import testtools @@ -56,9 +54,7 @@ class TestImage(testtools.TestCase): self.assertEqual(IDENTIFIER, sot.id) self.assertEqual(EXAMPLE['checksum'], sot.checksum) self.assertEqual(EXAMPLE['container_format'], sot.container_format) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) self.assertEqual(EXAMPLE['disk_format'], sot.disk_format) self.assertEqual(EXAMPLE['min_disk'], sot.min_disk) self.assertEqual(EXAMPLE['name'], sot.name) @@ -67,9 +63,7 @@ class TestImage(testtools.TestCase): self.assertFalse(sot.is_protected) self.assertEqual(EXAMPLE['status'], sot.status) self.assertEqual(EXAMPLE['tags'], sot.tags) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) self.assertEqual(EXAMPLE['virtual_size'], sot.virtual_size) self.assertEqual(EXAMPLE['visibility'], sot.visibility) diff --git a/openstack/tests/unit/image/v2/test_member.py b/openstack/tests/unit/image/v2/test_member.py index 3fb2e457..59dd884d 100644 --- a/openstack/tests/unit/image/v2/test_member.py +++ b/openstack/tests/unit/image/v2/test_member.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.image.v2 import member @@ -43,11 +41,7 @@ class TestMember(testtools.TestCase): def test_make_it(self): sot = member.Member(EXAMPLE) self.assertEqual(IDENTIFIER, sot.id) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) self.assertEqual(EXAMPLE['image_id'], sot.image_id) self.assertEqual(EXAMPLE['status'], sot.status) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/key_manager/v1/test_container.py b/openstack/tests/unit/key_manager/v1/test_container.py index 6aa7277a..7ab60ca2 100644 --- a/openstack/tests/unit/key_manager/v1/test_container.py +++ b/openstack/tests/unit/key_manager/v1/test_container.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.key_manager.v1 import container @@ -45,14 +43,10 @@ class TestContainer(testtools.TestCase): def test_make_it(self): sot = container.Container(EXAMPLE) self.assertEqual(EXAMPLE['container_ref'], sot.container_ref) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created'], sot.created_at) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['secret_refs'], sot.secret_refs) self.assertEqual(EXAMPLE['status'], sot.status) self.assertEqual(EXAMPLE['type'], sot.type) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated'], sot.updated_at) self.assertEqual(EXAMPLE['container_ref'], sot.id) diff --git a/openstack/tests/unit/key_manager/v1/test_secret.py b/openstack/tests/unit/key_manager/v1/test_secret.py index dd39cf91..6b09aa2d 100644 --- a/openstack/tests/unit/key_manager/v1/test_secret.py +++ b/openstack/tests/unit/key_manager/v1/test_secret.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.key_manager.v1 import secret @@ -49,14 +47,10 @@ class TestSecret(testtools.TestCase): self.assertEqual(EXAMPLE['algorithm'], sot.algorithm) self.assertEqual(EXAMPLE['bit_length'], sot.bit_length) self.assertEqual(EXAMPLE['content_types'], sot.content_types) - dt = datetime.datetime(2017, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.expires_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['expiration'], sot.expires_at) self.assertEqual(EXAMPLE['mode'], sot.mode) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['secret_ref'], sot.secret_ref) self.assertEqual(EXAMPLE['status'], sot.status) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated'], sot.updated_at) self.assertEqual(EXAMPLE['secret_ref'], sot.id) diff --git a/openstack/tests/unit/metric/v1/test_resource.py b/openstack/tests/unit/metric/v1/test_resource.py index cd325d3e..0a8617c0 100644 --- a/openstack/tests/unit/metric/v1/test_resource.py +++ b/openstack/tests/unit/metric/v1/test_resource.py @@ -9,7 +9,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import datetime import testtools @@ -53,7 +52,5 @@ class TestResource(testtools.TestCase): self.assertEqual(EXAMPLE_GENERIC['type'], r.type) self.assertEqual(EXAMPLE_GENERIC['id'], r.id) self.assertEqual(EXAMPLE_GENERIC['metrics'], r.metrics) - dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, r.started_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE_GENERIC['started_at'], r.started_at) self.assertEqual(EXAMPLE_GENERIC['ended_at'], r.ended_at) diff --git a/openstack/tests/unit/network/v2/test_agent.py b/openstack/tests/unit/network/v2/test_agent.py index 28c582d7..ccefadd1 100644 --- a/openstack/tests/unit/network/v2/test_agent.py +++ b/openstack/tests/unit/network/v2/test_agent.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.network.v2 import agent @@ -57,17 +55,10 @@ class TestAgent(testtools.TestCase): sot.availability_zone) self.assertEqual(EXAMPLE['binary'], sot.binary) self.assertEqual(EXAMPLE['configurations'], sot.configuration) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) self.assertEqual(EXAMPLE['description'], sot.description) - dt = datetime.datetime(2016, 8, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, - sot.last_heartbeat_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['heartbeat_timestamp'], sot.last_heartbeat_at) self.assertEqual(EXAMPLE['host'], sot.host) self.assertEqual(EXAMPLE['id'], sot.id) - dt = datetime.datetime(2016, 7, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.started_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['started_at'], sot.started_at) self.assertEqual(EXAMPLE['topic'], sot.topic) diff --git a/openstack/tests/unit/network/v2/test_extension.py b/openstack/tests/unit/network/v2/test_extension.py index 053b4521..e87293ad 100644 --- a/openstack/tests/unit/network/v2/test_extension.py +++ b/openstack/tests/unit/network/v2/test_extension.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.network.v2 import extension @@ -49,6 +47,4 @@ class TestExtension(testtools.TestCase): self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['namespace'], sot.namespace) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['updated'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_network.py b/openstack/tests/unit/network/v2/test_network.py index 35480eec..17692342 100644 --- a/openstack/tests/unit/network/v2/test_network.py +++ b/openstack/tests/unit/network/v2/test_network.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.network.v2 import network @@ -85,10 +83,6 @@ class TestNetwork(testtools.TestCase): self.assertEqual(EXAMPLE['ipv6_address_scope'], sot.ipv6_address_scope_id) self.assertEqual(EXAMPLE['description'], sot.description) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 7, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) self.assertFalse(sot.is_default) diff --git a/openstack/tests/unit/network/v2/test_port.py b/openstack/tests/unit/network/v2/test_port.py index b33d48b6..4c277417 100644 --- a/openstack/tests/unit/network/v2/test_port.py +++ b/openstack/tests/unit/network/v2/test_port.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.network.v2 import port @@ -85,9 +83,5 @@ class TestPort(testtools.TestCase): self.assertEqual(EXAMPLE['dns_assignment'], sot.dns_assignment) self.assertEqual(EXAMPLE['dns_name'], sot.dns_name) self.assertEqual(EXAMPLE['description'], sot.description) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 7, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_subnet.py b/openstack/tests/unit/network/v2/test_subnet.py index 56c60d85..407f158b 100644 --- a/openstack/tests/unit/network/v2/test_subnet.py +++ b/openstack/tests/unit/network/v2/test_subnet.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.network.v2 import subnet @@ -69,9 +67,5 @@ class TestSubnet(testtools.TestCase): self.assertEqual(EXAMPLE['tenant_id'], sot.project_id) self.assertEqual(EXAMPLE['subnetpool_id'], sot.subnet_pool_id) self.assertEqual(EXAMPLE['description'], sot.description) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 7, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) diff --git a/openstack/tests/unit/network/v2/test_subnet_pool.py b/openstack/tests/unit/network/v2/test_subnet_pool.py index 1642f640..cd1fd51d 100644 --- a/openstack/tests/unit/network/v2/test_subnet_pool.py +++ b/openstack/tests/unit/network/v2/test_subnet_pool.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.network.v2 import subnet_pool @@ -67,10 +65,6 @@ class TestSubnetpool(testtools.TestCase): self.assertTrue(sot.is_shared) self.assertEqual(EXAMPLE['address_scope_id'], sot.address_scope_id) self.assertEqual(EXAMPLE['description'], sot.description) - dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) - dt = datetime.datetime(2016, 7, 9, 12, 14, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['created_at'], sot.created_at) + self.assertEqual(EXAMPLE['updated_at'], sot.updated_at) self.assertTrue(sot.is_default) diff --git a/openstack/tests/unit/object_store/v1/test_account.py b/openstack/tests/unit/object_store/v1/test_account.py index 21dfe080..e0df5390 100644 --- a/openstack/tests/unit/object_store/v1/test_account.py +++ b/openstack/tests/unit/object_store/v1/test_account.py @@ -10,9 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from datetime import datetime -import iso8601 - import testtools from openstack.object_store.v1 import account @@ -56,6 +53,4 @@ class TestAccount(testtools.TestCase): sot.account_container_count) self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-object-count']), sot.account_object_count) - self.assertEqual(datetime(2016, 1, 21, 21, 59, 15, 889370, - tzinfo=iso8601.UTC), - sot.timestamp) + self.assertEqual(ACCOUNT_EXAMPLE['x-timestamp'], sot.timestamp) diff --git a/openstack/tests/unit/object_store/v1/test_container.py b/openstack/tests/unit/object_store/v1/test_container.py index 4d51f058..587c7e47 100644 --- a/openstack/tests/unit/object_store/v1/test_container.py +++ b/openstack/tests/unit/object_store/v1/test_container.py @@ -10,9 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from datetime import datetime -import iso8601 - import mock import testtools @@ -116,9 +113,7 @@ class TestContainer(testtools.TestCase): sot.sync_key) self.assertEqual(HEAD_EXAMPLE['x-versions-location'], sot.versions_location) - self.assertEqual(datetime(2016, 1, 21, 22, 7, 35, 486720, - tzinfo=iso8601.UTC), - sot.timestamp) + self.assertEqual(HEAD_EXAMPLE['x-timestamp'], sot.timestamp) @mock.patch("openstack.resource.Resource.list") def test_list(self, fake_list): diff --git a/openstack/tests/unit/object_store/v1/test_obj.py b/openstack/tests/unit/object_store/v1/test_obj.py index 903138b6..47a3b95a 100644 --- a/openstack/tests/unit/object_store/v1/test_obj.py +++ b/openstack/tests/unit/object_store/v1/test_obj.py @@ -10,9 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from datetime import datetime -import iso8601 - import mock import testtools @@ -98,13 +95,9 @@ class TestObject(testtools.TestCase): self.assertEqual(headers['accept-ranges'], sot.accept_ranges) self.assertEqual(headers['last-modified'], sot.last_modified_at) self.assertEqual(headers['etag'], sot.etag) - self.assertEqual(datetime(2016, 1, 21, 22, 10, 56, 281120, - tzinfo=iso8601.UTC), - sot.timestamp) + self.assertEqual(headers['x-timestamp'], sot.timestamp) self.assertEqual(headers['content-type'], sot.content_type) - self.assertEqual(datetime(2016, 1, 21, 22, 43, 46, 167440, - tzinfo=iso8601.UTC), - sot.delete_at) + self.assertEqual(headers['x-delete-at'], sot.delete_at) def test_get(self): sot = obj.Object.new(container=CONTAINER_NAME, name=OBJECT_NAME) diff --git a/openstack/tests/unit/orchestration/v1/test_resource.py b/openstack/tests/unit/orchestration/v1/test_resource.py index 86d0afbc..9a7371bb 100644 --- a/openstack/tests/unit/orchestration/v1/test_resource.py +++ b/openstack/tests/unit/orchestration/v1/test_resource.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.orchestration.v1 import resource @@ -64,6 +62,4 @@ class TestResource(testtools.TestCase): self.assertEqual(FAKE['resource_type'], sot.resource_type) self.assertEqual(FAKE['status'], sot.status) self.assertEqual(FAKE['status_reason'], sot.status_reason) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(FAKE['updated_time'], sot.updated_at) diff --git a/openstack/tests/unit/orchestration/v1/test_stack.py b/openstack/tests/unit/orchestration/v1/test_stack.py index 5e99bffa..e0e82bef 100644 --- a/openstack/tests/unit/orchestration/v1/test_stack.py +++ b/openstack/tests/unit/orchestration/v1/test_stack.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import six import testtools @@ -69,9 +67,7 @@ class TestStack(testtools.TestCase): def test_make_it(self): sot = stack.Stack(FAKE) self.assertEqual(FAKE['capabilities'], sot.capabilities) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) + self.assertEqual(FAKE['creation_time'], sot.created_at) self.assertEqual(FAKE['description'], sot.description) self.assertTrue(sot.is_rollback_disabled) self.assertEqual(FAKE['id'], sot.id) @@ -89,9 +85,7 @@ class TestStack(testtools.TestCase): self.assertEqual(FAKE['template_url'], sot.template_url) self.assertEqual(FAKE['timeout_mins'], sot.timeout_mins) - dt = datetime.datetime(2015, 3, 9, 12, 30, 00, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(FAKE['updated_time'], sot.updated_at) def test_create(self): resp = mock.Mock() diff --git a/openstack/tests/unit/telemetry/v2/test_alarm.py b/openstack/tests/unit/telemetry/v2/test_alarm.py index 5b81111c..08a92b98 100644 --- a/openstack/tests/unit/telemetry/v2/test_alarm.py +++ b/openstack/tests/unit/telemetry/v2/test_alarm.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import testtools @@ -84,12 +82,8 @@ class TestAlarm(testtools.TestCase): self.assertFalse(sot.is_repeat_actions) self.assertEqual(EXAMPLE['severity'], sot.severity) self.assertEqual(EXAMPLE['state'], sot.state) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.state_changed_at.replace(tzinfo=None)) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['state_timestamp'], sot.state_changed_at) + self.assertEqual(EXAMPLE['timestamp'], sot.updated_at) self.assertEqual(EXAMPLE['threshold_rule'], sot.threshold_rule) self.assertEqual(EXAMPLE['time_constraints'], sot.time_constraints) self.assertEqual(EXAMPLE['type'], sot.type) diff --git a/openstack/tests/unit/telemetry/v2/test_alarm_change.py b/openstack/tests/unit/telemetry/v2/test_alarm_change.py index 6f7a8043..94c9f3b0 100644 --- a/openstack/tests/unit/telemetry/v2/test_alarm_change.py +++ b/openstack/tests/unit/telemetry/v2/test_alarm_change.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import testtools @@ -52,9 +50,7 @@ class TestAlarmChange(testtools.TestCase): self.assertEqual(IDENTIFIER, sot.event_id) self.assertEqual(EXAMPLE['on_behalf_of'], sot.on_behalf_of_id) self.assertEqual(EXAMPLE['project_id'], sot.project_id) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.triggered_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['timestamp'], sot.triggered_at) self.assertEqual(EXAMPLE['type'], sot.type) self.assertEqual(EXAMPLE['user_id'], sot.user_id) @@ -73,8 +69,6 @@ class TestAlarmChange(testtools.TestCase): self.assertEqual(IDENTIFIER, first.event_id) self.assertEqual(EXAMPLE['on_behalf_of'], first.on_behalf_of_id) self.assertEqual(EXAMPLE['project_id'], first.project_id) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, first.triggered_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['timestamp'], first.triggered_at) self.assertEqual(EXAMPLE['type'], first.type) self.assertEqual(EXAMPLE['user_id'], first.user_id) diff --git a/openstack/tests/unit/telemetry/v2/test_resource.py b/openstack/tests/unit/telemetry/v2/test_resource.py index 522d62ff..6c574dea 100644 --- a/openstack/tests/unit/telemetry/v2/test_resource.py +++ b/openstack/tests/unit/telemetry/v2/test_resource.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import testtools from openstack.telemetry.v2 import resource @@ -48,12 +46,10 @@ class TestResource(testtools.TestCase): def test_make_it(self): sot = resource.Resource(EXAMPLE) self.assertEqual(EXAMPLE['resource_id'], sot.id) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.first_sample_at.replace(tzinfo=None)) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.last_sample_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['first_sample_timestamp'], + sot.first_sample_at) + self.assertEqual(EXAMPLE['last_sample_timestamp'], + sot.last_sample_at) self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['metadata'], sot.metadata) self.assertEqual(EXAMPLE['project_id'], sot.project_id) diff --git a/openstack/tests/unit/telemetry/v2/test_sample.py b/openstack/tests/unit/telemetry/v2/test_sample.py index c830e7a8..07b06de4 100644 --- a/openstack/tests/unit/telemetry/v2/test_sample.py +++ b/openstack/tests/unit/telemetry/v2/test_sample.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import testtools @@ -68,14 +66,10 @@ class TestSample(testtools.TestCase): self.assertEqual(SAMPLE['metadata'], sot.metadata) self.assertEqual(SAMPLE['counter_name'], sot.counter_name) self.assertEqual(SAMPLE['project_id'], sot.project_id) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.recorded_at.replace(tzinfo=None)) + self.assertEqual(SAMPLE['recorded_at'], sot.recorded_at) self.assertEqual(SAMPLE['resource_id'], sot.resource_id) self.assertEqual(SAMPLE['source'], sot.source) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.generated_at.replace(tzinfo=None)) + self.assertEqual(SAMPLE['timestamp'], sot.generated_at) self.assertEqual(SAMPLE['type'], sot.type) self.assertEqual(SAMPLE['unit'], sot.unit) self.assertEqual(SAMPLE['user_id'], sot.user_id) @@ -89,15 +83,11 @@ class TestSample(testtools.TestCase): self.assertEqual(OLD_SAMPLE['counter_unit'], sot.unit) self.assertEqual(OLD_SAMPLE['counter_volume'], sot.volume) self.assertEqual(OLD_SAMPLE['project_id'], sot.project_id) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.recorded_at.replace(tzinfo=None)) + self.assertEqual(OLD_SAMPLE['recorded_at'], sot.recorded_at) self.assertEqual(OLD_SAMPLE['resource_id'], sot.resource_id) self.assertEqual(OLD_SAMPLE['resource_metadata'], sot.metadata) self.assertEqual(OLD_SAMPLE['source'], sot.source) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, sot.generated_at.replace(tzinfo=None)) + self.assertEqual(OLD_SAMPLE['timestamp'], sot.generated_at) self.assertEqual(OLD_SAMPLE['user_id'], sot.user_id) def test_list(self): @@ -113,14 +103,10 @@ class TestSample(testtools.TestCase): self.assertEqual(SAMPLE['metadata'], first.metadata) self.assertEqual(SAMPLE['counter_name'], first.counter_name) self.assertEqual(SAMPLE['project_id'], first.project_id) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, first.recorded_at.replace(tzinfo=None)) + self.assertEqual(SAMPLE['recorded_at'], first.recorded_at) self.assertEqual(SAMPLE['resource_id'], first.resource_id) self.assertEqual(SAMPLE['source'], first.source) - dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( - tzinfo=None) - self.assertEqual(dt, first.generated_at.replace(tzinfo=None)) + self.assertEqual(SAMPLE['timestamp'], first.generated_at) self.assertEqual(SAMPLE['type'], first.type) self.assertEqual(SAMPLE['unit'], first.unit) self.assertEqual(SAMPLE['user_id'], first.user_id) diff --git a/openstack/tests/unit/telemetry/v2/test_statistics.py b/openstack/tests/unit/telemetry/v2/test_statistics.py index 2f868347..2717c022 100644 --- a/openstack/tests/unit/telemetry/v2/test_statistics.py +++ b/openstack/tests/unit/telemetry/v2/test_statistics.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime - import mock import testtools @@ -56,22 +54,14 @@ class TestStatistics(testtools.TestCase): self.assertEqual(EXAMPLE['avg'], sot.avg) self.assertEqual(EXAMPLE['count'], sot.count) self.assertEqual(EXAMPLE['duration'], sot.duration) - dt = datetime.datetime(2015, 3, 9, 12, 45, 00, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.duration_end_at.replace(tzinfo=None)) - dt = datetime.datetime(2015, 3, 9, 12, 15, 00, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.duration_start_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['duration_end'], sot.duration_end_at) + self.assertEqual(EXAMPLE['duration_start'], sot.duration_start_at) self.assertEqual(EXAMPLE['groupby'], sot.group_by) self.assertEqual(EXAMPLE['max'], sot.max) self.assertEqual(EXAMPLE['min'], sot.min) self.assertEqual(EXAMPLE['period'], sot.period) - dt = datetime.datetime(2015, 3, 9, 12, 45, 00, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.period_end_at.replace(tzinfo=None)) - dt = datetime.datetime(2015, 3, 9, 12, 15, 00, 000000).replace( - tzinfo=None) - self.assertEqual(dt, sot.period_start_at.replace(tzinfo=None)) + self.assertEqual(EXAMPLE['period_end'], sot.period_end_at) + self.assertEqual(EXAMPLE['period_start'], sot.period_start_at) self.assertEqual(EXAMPLE['sum'], sot.sum) self.assertEqual(EXAMPLE['unit'], sot.unit) diff --git a/openstack/tests/unit/test_format.py b/openstack/tests/unit/test_format.py index c3d8f2ed..f78454dd 100644 --- a/openstack/tests/unit/test_format.py +++ b/openstack/tests/unit/test_format.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from datetime import datetime -from iso8601 import iso8601 import testtools from openstack import format @@ -38,69 +36,3 @@ class TestBoolStrFormatter(testtools.TestCase): self.assertRaises(ValueError, format.BoolStr.serialize, None) self.assertRaises(ValueError, format.BoolStr.serialize, '') self.assertRaises(ValueError, format.BoolStr.serialize, 'True') - - -class TestISO8601Formatter(testtools.TestCase): - - def test_deserialize(self): - self.assertEqual( - format.ISO8601.deserialize("2015-06-27T05:09:43"), - datetime(2015, 6, 27, 5, 9, 43, tzinfo=iso8601.UTC)) - self.assertEqual( - format.ISO8601.deserialize("2012-03-28T21:31:02Z"), - datetime(2012, 3, 28, 21, 31, 2, tzinfo=iso8601.UTC)) - self.assertEqual( - format.ISO8601.deserialize("2013-09-23T13:53:12.774549"), - datetime(2013, 9, 23, 13, 53, 12, 774549, tzinfo=iso8601.UTC)) - self.assertEqual( - format.ISO8601.deserialize("2015-08-27T09:49:58-05:00"), - datetime(2015, 8, 27, 9, 49, 58, - tzinfo=iso8601.FixedOffset(-5, 0, "-05:00"))) - - def test_serialize(self): - self.assertEqual( - format.ISO8601.serialize( - datetime(2015, 6, 27, 5, 9, 43, tzinfo=iso8601.UTC)), - "2015-06-27T05:09:43+00:00") - self.assertEqual( - format.ISO8601.serialize( - datetime(2012, 3, 28, 21, 31, 2, tzinfo=iso8601.UTC)), - "2012-03-28T21:31:02+00:00") - self.assertEqual( - format.ISO8601.serialize( - datetime(2013, 9, 23, 13, 53, 12, 774549, tzinfo=iso8601.UTC)), - "2013-09-23T13:53:12.774549+00:00") - self.assertEqual( - format.ISO8601.serialize( - datetime(2015, 8, 27, 9, 49, 58, - tzinfo=iso8601.FixedOffset(-5, 0, "-05:00"))), - "2015-08-27T09:49:58-05:00") - - -class TestUNIXEpochFormatter(testtools.TestCase): - - def test_deserialize(self): - self.assertEqual(format.UNIXEpoch.deserialize(1453412616.02406), - datetime(2016, 1, 21, 21, 43, 36, 24060, - tzinfo=iso8601.UTC)) - self.assertEqual(format.UNIXEpoch.deserialize(1389453423.35964), - datetime(2014, 1, 11, 15, 17, 3, 359640, - tzinfo=iso8601.UTC)) - self.assertEqual(format.UNIXEpoch.deserialize(1389453423), - datetime(2014, 1, 11, 15, 17, 3, tzinfo=iso8601.UTC)) - self.assertRaises(ValueError, format.UNIXEpoch.deserialize, "lol") - - def test_serialize(self): - self.assertEqual( - format.UNIXEpoch.serialize( - datetime(2016, 1, 21, 21, 43, 36, 24060, tzinfo=iso8601.UTC)), - 1453412616.02406) - self.assertEqual( - format.UNIXEpoch.serialize( - datetime(2014, 1, 11, 15, 17, 3, 359640, tzinfo=iso8601.UTC)), - 1389453423.35964) - self.assertEqual( - format.UNIXEpoch.serialize( - datetime(2014, 1, 11, 15, 17, 3, tzinfo=iso8601.UTC)), - 1389453423) - self.assertRaises(ValueError, format.UNIXEpoch.serialize, "lol") diff --git a/requirements.txt b/requirements.txt index 4e9d2791..0cd25684 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,5 @@ pbr>=1.6 # Apache-2.0 six>=1.9.0 # MIT stevedore>=1.10.0 # Apache-2.0 -oslo.utils>=3.11.0 # Apache-2.0 os-client-config>=1.13.1 # Apache-2.0 keystoneauth1>=2.1.0 # Apache-2.0 -iso8601>=0.1.11 # MIT