1
1
"""Gherkin step implementations for core properties-related features."""
2
2
3
- from datetime import datetime , timedelta
3
+ import datetime as dt
4
4
5
5
from behave import given , then , when
6
6
from behave .runner import Context
@@ -38,13 +38,13 @@ def when_I_assign_new_values_to_the_properties(context: Context):
38
38
("category" , "Category" ),
39
39
("comments" , "Description" ),
40
40
("content_status" , "Content Status" ),
41
- ("created" , datetime (2013 , 6 , 15 , 12 , 34 , 56 )),
41
+ ("created" , dt . datetime (2013 , 6 , 15 , 12 , 34 , 56 , tzinfo = dt . timezone . utc )),
42
42
("identifier" , "Identifier" ),
43
43
("keywords" , "key; word; keyword" ),
44
44
("language" , "Language" ),
45
45
("last_modified_by" , "Last Modified By" ),
46
- ("last_printed" , datetime (2013 , 6 , 15 , 12 , 34 , 56 )),
47
- ("modified" , datetime (2013 , 6 , 15 , 12 , 34 , 56 )),
46
+ ("last_printed" , dt . datetime (2013 , 6 , 15 , 12 , 34 , 56 , tzinfo = dt . timezone . utc )),
47
+ ("modified" , dt . datetime (2013 , 6 , 15 , 12 , 34 , 56 , tzinfo = dt . timezone . utc )),
48
48
("revision" , 9 ),
49
49
("subject" , "Subject" ),
50
50
("title" , "Title" ),
@@ -66,8 +66,8 @@ def then_a_core_properties_part_with_default_values_is_added(context: Context):
66
66
assert core_properties .revision == 1
67
67
# core_properties.modified only stores time with seconds resolution, so
68
68
# comparison needs to be a little loose (within two seconds)
69
- modified_timedelta = datetime .utcnow ( ) - core_properties .modified
70
- max_expected_timedelta = timedelta (seconds = 2 )
69
+ modified_timedelta = dt . datetime .now ( dt . timezone . utc ) - core_properties .modified
70
+ max_expected_timedelta = dt . timedelta (seconds = 2 )
71
71
assert modified_timedelta < max_expected_timedelta
72
72
73
73
@@ -85,13 +85,13 @@ def then_the_core_property_values_match_the_known_values(context: Context):
85
85
("category" , "Category" ),
86
86
("comments" , "Description" ),
87
87
("content_status" , "Content Status" ),
88
- ("created" , datetime (2014 , 12 , 13 , 22 , 2 , 0 )),
88
+ ("created" , dt . datetime (2014 , 12 , 13 , 22 , 2 , 0 , tzinfo = dt . timezone . utc )),
89
89
("identifier" , "Identifier" ),
90
90
("keywords" , "key; word; keyword" ),
91
91
("language" , "Language" ),
92
92
("last_modified_by" , "Steve Canny" ),
93
- ("last_printed" , datetime (2014 , 12 , 13 , 22 , 2 , 42 )),
94
- ("modified" , datetime (2014 , 12 , 13 , 22 , 6 , 0 )),
93
+ ("last_printed" , dt . datetime (2014 , 12 , 13 , 22 , 2 , 42 , tzinfo = dt . timezone . utc )),
94
+ ("modified" , dt . datetime (2014 , 12 , 13 , 22 , 6 , 0 , tzinfo = dt . timezone . utc )),
95
95
("revision" , 2 ),
96
96
("subject" , "Subject" ),
97
97
("title" , "Title" ),
0 commit comments