<s> from nose . tools import raises <EOL> from flask import Flask <EOL> from flask_shorturl import ShortUrl <EOL> def test_shorturl ( ) : <EOL> app = Flask ( __name__ ) <EOL> su = ShortUrl ( app ) <EOL> for a in range ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ) : <EOL> b = su . encode ( a ) <EOL> c = su . enbase ( b ) <EOL> d = su . debase ( c ) <EOL> e = su . decode ( d ) <EOL> assert a == e <EOL> assert b == d <EOL> assert c == su . encode_url ( a ) <EOL> assert a == su . decode_url ( c ) <EOL> def test_init_app ( ) : <EOL> app = Flask ( __name__ ) <EOL> su = ShortUrl ( ) <EOL> su . init_app ( app ) <EOL> a = <NUM_LIT> <EOL> b = su . encode ( a ) <EOL> c = su . enbase ( b ) <EOL> d = su . debase ( c ) <EOL> e = su . decode ( d ) <EOL> assert a == e <EOL> assert b == d <EOL> assert c == su . encode_url ( a ) <EOL> assert a == su . decode_url ( c ) <EOL> def test_flask_ctx ( ) : <EOL> app = Flask ( __name__ ) <EOL> DEFAULT_ALPHABET = '<STR_LIT>' <EOL> app . config . setdefault ( '<STR_LIT>' , DEFAULT_ALPHABET ) <EOL> app . config . setdefault ( '<STR_LIT>' , <NUM_LIT:5> ) <EOL> app . config . setdefault ( '<STR_LIT>' , <NUM_LIT> ) <EOL> su = ShortUrl ( ) <EOL> with app . test_request_context ( ) : <EOL> a = <NUM_LIT> <EOL> b = su . encode ( a ) <EOL> c = su . enbase ( b ) <EOL> d = su . debase ( c ) <EOL> e = su . decode ( d ) <EOL> assert a == e <EOL> assert b == d <EOL> assert c == su . encode_url ( a ) <EOL> assert a == su . decode_url ( c ) <EOL> @ raises ( RuntimeError ) <EOL> def test_no_ctx ( ) : <EOL> su = ShortUrl ( ) <EOL> su . encode ( <NUM_LIT> ) </s>
