<s> from hashids import Hashids <EOL> import pytest <EOL> class TestConstructor ( object ) : <EOL> def test_small_alphabet ( self ) : <EOL> pytest . raises ( ValueError , Hashids , alphabet = '<STR_LIT>' ) <EOL> class TestEncoding ( object ) : <EOL> def test_empty_call ( self ) : <EOL> assert Hashids ( ) . encode ( ) == '<STR_LIT>' <EOL> def test_default_salt ( self ) : <EOL> assert Hashids ( ) . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> def test_single_number ( self ) : <EOL> h = Hashids ( ) <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_multiple_numbers ( self ) : <EOL> h = Hashids ( ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:5> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_salt ( self ) : <EOL> h = Hashids ( salt = '<STR_LIT>' ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:5> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_alphabet ( self ) : <EOL> h = Hashids ( alphabet = '<STR_LIT>' ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:32> , <NUM_LIT:5> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_min_length ( self ) : <EOL> h = Hashids ( min_length = <NUM_LIT> ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_all_parameters ( self ) : <EOL> h = Hashids ( '<STR_LIT>' , <NUM_LIT:16> , '<STR_LIT>' ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_alphabet_without_standard_separators ( self ) : <EOL> h = Hashids ( alphabet = '<STR_LIT>' ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_alphabet_with_two_standard_separators ( self ) : <EOL> h = Hashids ( alphabet = '<STR_LIT>' ) <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> ) == '<STR_LIT>' <EOL> assert h . encode ( <NUM_LIT> , <NUM_LIT> ) == '<STR_LIT>' <EOL> def test_negative_call ( self ) : <EOL> assert Hashids ( ) . encode ( <NUM_LIT:1> , - <NUM_LIT:2> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> def test_float_call ( self ) : <EOL> assert Hashids ( ) . encode ( <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> ) == '<STR_LIT>' <EOL> def test_encode_hex ( self ) : <EOL> assert Hashids ( ) . encode_hex ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> assert len ( Hashids ( min_length = <NUM_LIT:1000> ) . encode_hex ( '<STR_LIT>' ) ) >= <NUM_LIT:1000> <EOL> assert Hashids ( ) . encode_hex ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> def test_illegal_hex ( self ) : <EOL> assert Hashids ( ) . encode_hex ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> assert Hashids ( ) . encode_hex ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> class TestDecoding ( object ) : <EOL> def test_empty_string ( self ) : <EOL> assert Hashids ( ) . decode ( '<STR_LIT>' ) == ( ) <EOL> def test_non_string ( self ) : <EOL> assert Hashids ( ) . decode ( object ( ) ) == ( ) <EOL> def test_default_salt ( self ) : <EOL> assert Hashids ( ) . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> def test_empty_call ( self ) : <EOL> assert Hashids ( ) . decode ( '<STR_LIT>' ) == ( ) <EOL> def test_single_number ( self ) : <EOL> h = Hashids ( ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> def test_multiple_numbers ( self ) : <EOL> h = Hashids ( ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:5> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_salt ( self ) : <EOL> h = Hashids ( salt = '<STR_LIT>' ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:5> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_alphabet ( self ) : <EOL> h = Hashids ( alphabet = '<STR_LIT>' ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:32> , <NUM_LIT:5> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_min_length ( self ) : <EOL> h = Hashids ( min_length = <NUM_LIT> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_all_parameters ( self ) : <EOL> h = Hashids ( '<STR_LIT>' , <NUM_LIT:16> , '<STR_LIT>' ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_invalid_hash ( self ) : <EOL> assert Hashids ( alphabet = '<STR_LIT>' ) . decode ( '<STR_LIT>' ) == ( ) <EOL> def test_alphabet_without_standard_separators ( self ) : <EOL> h = Hashids ( alphabet = '<STR_LIT>' ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_alphabet_with_two_standard_separators ( self ) : <EOL> h = Hashids ( alphabet = '<STR_LIT>' ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , ) <EOL> assert h . decode ( '<STR_LIT>' ) == ( <NUM_LIT> , <NUM_LIT> ) <EOL> def test_only_one_valid ( self ) : <EOL> h = Hashids ( min_length = <NUM_LIT:6> ) <EOL> assert h . decode ( h . encode ( <NUM_LIT:1> ) [ : - <NUM_LIT:1> ] + '<STR_LIT:0>' ) == ( ) <EOL> def test_decode_hex ( self ) : <EOL> hex_str = '<STR_LIT>' <EOL> assert Hashids ( ) . decode_hex ( '<STR_LIT>' ) == hex_str <EOL> h = Hashids ( min_length = <NUM_LIT:1000> ) <EOL> assert h . decode_hex ( h . encode_hex ( hex_str ) ) == hex_str <EOL> assert Hashids ( ) . decode_hex ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> def test_illegal_decode_hex ( self ) : <EOL> assert Hashids ( ) . decode_hex ( '<STR_LIT>' ) == '<STR_LIT>' <EOL> assert Hashids ( ) . decode_hex ( '<STR_LIT>' ) == '<STR_LIT>' </s>
