def test_multiline_input(): emojifier = emoji_it() expected = ["And if you sing", "though as angels"] input_lines = ['🙈🍶🤣 🏉🌹 📜🥪🏫 🎷🏉🍶🏵', '🧣📍🥪🏫🏵📍 🚀🎷 🚀🍶🏵🐓😥🎷'] for i in range(len(expected)): assert emojifier.decrypt(input_lines[i]) == expected[i]
def encrypt(): form = EncryptForm() if form.validate_on_submit(): #received message from form message = form.message.data multiplier = form.multiplier.data # choice = form.key.data # options = {u'U+1F680' : ':rocket:', u'U+1F4DC' : ':scroll:')} key = form.key.data #instantiate class emoji_encrypt_class = emoji_it() #rewrite message with encrypted message emoji_encrypt_class.emoji_key = key emoji_encrypt_class.multiplier = multiplier message = emoji_encrypt_class.encrypt(message) flash('Successfully encrypted!') return render_template('encrypt.html', form=form, message=message) return render_template('encrypt.html', form=form)
def test_cipher_duplicate(): cipher = emoji_it() cipher.multiplier = 26 #create cipher dictionary cipher_dict = cipher.define_cipher() for value in cipher_dict.values(): counter = 0 for value2 in cipher_dict.values(): if value == value2: counter += 1 assert counter == 1 #value should only match value2 once per iteration
def game(): json_url = os.path.join(os.path.realpath(os.path.dirname(__file__)), "static", "puzzles.json") puzzles = json.load(open(json_url)) puzzle_index = random.randint(0, len(puzzles) - 1) puzzle = puzzles[puzzle_index] #hot swap the 'encrypted' message. message = puzzle['decrypted'] multiplier = random.randint(1, 100) emoji_encrypt_class = emoji_it() emoji_encrypt_class.multiplier = multiplier message = emoji_encrypt_class.encrypt(message) puzzle['encrypted'] = message return render_template('game.html', puzzle=puzzle)
def test_decryption_2(): emojifier = emoji_it() assert emojifier.decrypt('🏫⛵ ! ?') == "um ! ?"
def test_encryption_2(): emojifier = emoji_it() assert emojifier.encrypt("um ! ?") == '🏫⛵ ! ?'
def test_default_sanity(): cipher = emoji_it() assert cipher.emoji_key == ':rocket:' assert cipher.multiplier == 1
def test_encryption_1(): emojifier = emoji_it() assert emojifier.encrypt("hello") == '📍🐓😥😥🥪'
def test_multiline_input(): emojifier = emoji_it() input = "You work that you may keep pace\nwith the earth\nand the soul of the earth." expected_output = "🔀🥪🏫 ✂🥪🦕👟 🧣📍🚀🧣 📜🥪🏫 ⛵🚀📜 👟🐓🐓🛰 🛰🚀🎢🐓\n✂🏉🧣📍 🧣📍🐓 🐓🚀🦕🧣📍\n🚀🍶🤣 🧣📍🐓 🎷🥪🏫😥 🥪🌹 🧣📍🐓 🐓🚀🦕🧣📍." assert emojifier.encrypt(input) == expected_output
def test_numbers(): emojifier = emoji_it() assert emojifier.encrypt("806-672-3455") == '⛷🤘🕡-🕡🕕🤘🏻-🤘🏾🤘🏼🤘🏽🤘🏽'
def test_empty_input(): emojifier = emoji_it() assert emojifier.encrypt('') == ''
def test_chinese_korean(): emojifier = emoji_it() assert emojifier.encrypt("漢字ㄲ, ㄸ, ㅃ, ㅆ, ㅉ") == '漢字ㄲ, ㄸ, ㅃ, ㅆ, ㅉ'
def test_de_nonAlphabet_or_numbers(): emojifier = emoji_it() assert emojifier.decrypt( "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } " ) == "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
def test_decryption_1(): emojifier = emoji_it() assert emojifier.decrypt('📍🐓😥😥🥪') == 'hello'
def test_de_numbers(): emojifier = emoji_it() assert emojifier.decrypt('⛷🤘🕡-🕡🕕🤘🏻-🤘🏾🤘🏼🤘🏽🤘🏽') == "806-672-3455"