コード例 #1
0
ファイル: test_scaler.py プロジェクト: Stratouklos/BloomKata
def test_small_scales_throw_error():
    with pytest.raises(ValueError):
        scaler.scale_down([], 255)
コード例 #2
0
ファイル: test_scaler.py プロジェクト: Stratouklos/BloomKata
def test_a_wrap_around_case():
    assert scaler.scale_down("ffff", 65535 - 335) == 335
コード例 #3
0
ファイル: test_scaler.py プロジェクト: Stratouklos/BloomKata
def test_a_random_hash():
    m = sha256()
    m.update("adfa21341231sdasfc".encode("utf-8"))
    assert 256 < scaler.scale_down(m.hexdigest(), 65535) < 65535
コード例 #4
0
ファイル: test_scaler.py プロジェクト: Stratouklos/BloomKata
def test_scale_a_high_value():
    assert scaler.scale_down("ff", 256) == 255
コード例 #5
0
ファイル: test_scaler.py プロジェクト: Stratouklos/BloomKata
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)