示例#1
0
def test_small_scales_throw_error():
    with pytest.raises(ValueError):
        scaler.scale_down([], 255)
示例#2
0
def test_a_wrap_around_case():
    assert scaler.scale_down("ffff", 65535 - 335) == 335
示例#3
0
def test_a_random_hash():
    m = sha256()
    m.update("adfa21341231sdasfc".encode("utf-8"))
    assert 256 < scaler.scale_down(m.hexdigest(), 65535) < 65535
示例#4
0
def test_scale_a_high_value():
    assert scaler.scale_down("ff", 256) == 255
示例#5
0
def test_empty_digit_array_throws_error():
    with pytest.raises(TypeError):
        scaler.scale_down(None, 256)
示例#6
0
 def get_index(self, item):
     function = hashlib.new(self.hashName, item.encode('UTF-8'))
     hexhash = function.hexdigest()
     return scaler.scale_down(hexhash, self.size)