Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9343912
test_utils.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
test_utils.py
View Options
# Copyright (C) 2015-2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
pytest
from
swh.loader.git
import
utils
class
TestUtils
:
def
test_check_date_time
(
self
):
"""A long as datetime is fine, date time check does not raise
"""
for
e
in
range
(
32
,
37
):
ts
=
2
**
e
utils
.
check_date_time
(
ts
)
def
test_check_date_time_empty_value
(
self
):
assert
utils
.
check_date_time
(
None
)
is
None
def
test_check_date_time_raises
(
self
):
"""From a give threshold, check will no longer works.
"""
exp
=
38
timestamp
=
2
**
exp
with
pytest
.
raises
(
ValueError
,
match
=
".*is out of range.*"
):
utils
.
check_date_time
(
timestamp
)
def
test_ignore_branch_name
():
branches
=
{
b
"HEAD"
,
b
"refs/heads/master"
,
b
"refs/{}"
,
b
"refs/pull/10/head"
,
b
"refs/pull/100/head"
,
b
"refs/pull/xyz/merge"
,
# auto-merged GitHub pull requests filtered out
b
"refs/^{}"
,
# Peeled refs filtered out
}
actual_branches
=
{
b
for
b
in
branches
if
not
utils
.
ignore_branch_name
(
b
)}
assert
actual_branches
==
set
(
[
b
"HEAD"
,
b
"refs/heads/master"
,
b
"refs/{}"
,
b
"refs/pull/10/head"
,
b
"refs/pull/100/head"
,
]
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Fri, Jul 4, 1:57 PM (2 d, 11 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3355800
Attached To
rDLDG Git loader
Event Timeline
Log In to Comment