Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9344067
test_cassandra_converters.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_cassandra_converters.py
View Options
# Copyright (C) 2020 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
from
collections
import
namedtuple
from
typing
import
List
from
swh.model.hashutil
import
DEFAULT_ALGORITHMS
from
swh.storage.cassandra
import
converters
# Test purposes
field_names
:
List
[
str
]
=
list
(
DEFAULT_ALGORITHMS
)
Row
=
namedtuple
(
"Row"
,
field_names
)
# type: ignore
def
test_row_to_content_hashes
():
for
row
in
[
Row
(
sha1
=
b
"4
\x97
2t
\xcc\xef
j
\xb4\xdf\xaa\xf8
e
\x99
y/
\xa9\xc3\xfe
F
\x89
"
,
sha1_git
=
b
"
\xd8\x1c\xc0
q
\x0e\xb6\xcf\x9e\xfd
[
\x92\n\x84
S
\xe1\xe0
qW
\xb6\xcd
"
,
# noqa
sha256
=
b
"g6P
\xf9
6
\xcb
;
\n
/
\x93\xce\t\xd8\x1b\xe1\x07
H
\xb1\xb2\x03\xc1\x9e\x81
v
\xb4\xee\xfc\x19
d
\xa0\xcf
:"
,
# noqa
blake2s256
=
b
"
\xd5\xfe\x19
9We'
\xe4
,
\xfd
v
\xa9
EZ$2
\xfe\x7f
Vf
\x95
dW}
\xd9
<B
\x80\xe7
mf
\x1d
"
,
# noqa
),
Row
(
sha1
=
b
"4
\x97
2t
\xcc\xef
j
\xb4\xdf\xaa\xf8
e
\x99
y/
\xa9\xc3\xfe
F
\x89
"
,
# noqa
sha1_git
=
b
"
\xd8\x1c\xc0
q
\x0e\xb6\xcf\x9e\xfd
[
\x92\n\x84
S
\xe1\xe0
qW
\xb6\xcd
"
,
# noqa
sha256
=
b
"h6P
\xf9
6
\xcb
;
\n
/
\x93\xce\t\xd8\x1b\xe1\x07
H
\xb1\xb2\x03\xc1\x9e\x81
v
\xb4\xee\xfc\x19
d
\xa0\xcf
:"
,
# noqa
blake2s256
=
b
"
\xd5\xfe\x19
9We'
\xe4
,
\xfd
v
\xa9
EZ$2
\xfe\x7f
Vf
\x95
dW}
\xd9
<B
\x80\xe7
mf
\x1d
"
,
# noqa
),
]:
actual_hashes
=
converters
.
row_to_content_hashes
(
row
)
assert
len
(
actual_hashes
)
==
len
(
DEFAULT_ALGORITHMS
)
for
algo
in
DEFAULT_ALGORITHMS
:
assert
actual_hashes
[
algo
]
==
getattr
(
row
,
algo
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Fri, Jul 4, 2:05 PM (1 d, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3239655
Attached To
rDSTO Storage manager
Event Timeline
Log In to Comment