Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
41b43b9b
Commit
41b43b9b
authored
Jun 21, 2021
by
Matias Guijarro
Browse files
Merge branch 'fix-test-settings-dangling' into 'master'
CI: Fix dangling test in settings Closes
#2561
See merge request
!3809
parents
41a9b157
9b160052
Pipeline
#49138
failed with stages
in 50 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/config/test_settings.py
View file @
41b43b9b
...
...
@@ -579,30 +579,34 @@ def test_wardrobe_get_current_instance(session):
def
test_creation_time
(
session
):
drinks
=
settings
.
ParametersWardrobe
(
"drinks"
)
# an empty Wardrobe has only creation/access info
assert
len
(
drinks
.
to_dict
(
export_properties
=
True
))
==
3
assert
"wine"
not
in
drinks
.
instances
drinks
.
switch
(
"wine"
)
# get current time
now
=
datetime
.
datetime
.
now
()
# convert string to datetime obj
creation_date
=
datetime
.
datetime
.
strptime
(
drinks
.
creation_date
,
"%Y-%m-%d %H:%M:%S"
)
assert
abs
(
now
-
creation_date
)
<
datetime
.
timedelta
(
seconds
=
60
)
last_accessed
=
datetime
.
datetime
.
strptime
(
drinks
.
last_accessed
,
"%Y-%m-%d %H:%M:%S"
)
assert
abs
(
now
-
last_accessed
)
<
datetime
.
timedelta
(
seconds
=
60
)
# an empty Wardrobe has only creation/access info
food
=
settings
.
ParametersWardrobe
(
"food"
)
assert
len
(
food
.
to_dict
(
export_properties
=
True
))
==
3
def
str2datetime
(
string
):
return
datetime
.
datetime
.
strptime
(
string
,
"%Y-%m-%d %H:%M:%S"
)
food
.
switch
(
"first"
)
food
.
switch
(
"default"
)
# epsilon time bellow which time comparison is considered to be the same
# This value is pretty big to make sure the CI machine is fast enough
epsilon
=
datetime
.
timedelta
(
seconds
=
2
).
total_seconds
()
# creation and last access was done now
now
=
datetime
.
datetime
.
now
()
creation_date
=
str2datetime
(
drinks
.
creation_date
)
assert
creation_date
.
timestamp
()
==
pytest
.
approx
(
now
.
timestamp
(),
abs
=
epsilon
)
last_accessed
=
str2datetime
(
drinks
.
last_accessed
)
assert
last_accessed
.
timestamp
()
==
pytest
.
approx
(
now
.
timestamp
(),
abs
=
epsilon
)
# a later access update the last access time
gevent
.
sleep
(
1
)
food
.
creation_date
# access it => will change 'last_accessed'
assert
food
.
creation_date
==
str
(
creation_date
)
assert
food
.
last_accessed
!=
str
(
creation_date
)
drinks
.
creation_date
# access it => will change 'last_accessed'
now
=
datetime
.
datetime
.
now
()
last_accessed2
=
str2datetime
(
drinks
.
last_accessed
)
assert
last_accessed
!=
last_accessed2
,
"last_accessed was not updated"
assert
last_accessed2
.
timestamp
()
==
pytest
.
approx
(
now
.
timestamp
(),
abs
=
epsilon
)
def
test_from_dict_ok
(
session
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment