2022-04-20 12:08:38 +00:00
|
|
|
from mdevaluate import checksum
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
def test_checksum():
|
|
|
|
salt = checksum.SALT
|
2023-12-18 13:47:22 +00:00
|
|
|
checksum.SALT = ""
|
2022-04-20 12:08:38 +00:00
|
|
|
assert checksum.checksum(1) == 304942582444936629325699363757435820077590259883
|
2023-12-18 13:47:22 +00:00
|
|
|
assert checksum.checksum("42") == checksum.checksum(42)
|
2022-04-20 12:08:38 +00:00
|
|
|
cs1 = checksum.checksum(999)
|
2023-12-18 13:47:22 +00:00
|
|
|
checksum.SALT = "999"
|
2022-04-20 12:08:38 +00:00
|
|
|
assert cs1 != checksum.checksum(999)
|
|
|
|
|
|
|
|
a = np.array([1, 2, 3])
|
|
|
|
assert checksum.checksum(a) == checksum.checksum(a.tobytes())
|
|
|
|
|
|
|
|
checksum.SALT = salt
|
|
|
|
|
|
|
|
|
|
|
|
def test_version():
|
|
|
|
@checksum.version(1)
|
|
|
|
def f1():
|
|
|
|
pass
|
|
|
|
|
|
|
|
cs1 = checksum.checksum(f1)
|
|
|
|
|
|
|
|
@checksum.version(1)
|
|
|
|
def f1(x, y):
|
|
|
|
return x + y
|
|
|
|
|
|
|
|
assert cs1 == checksum.checksum(f1)
|
|
|
|
|
|
|
|
@checksum.version(2)
|
|
|
|
def f1(x, y):
|
|
|
|
pass
|
|
|
|
|
|
|
|
assert cs1 != checksum.checksum(f1)
|