コード例 #1
0
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]
コード例 #2
0
ファイル: routes.py プロジェクト: aelydens/teamworldbot
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)
コード例 #3
0
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)
コード例 #4
0
ファイル: test_cipher.py プロジェクト: aelydens/teamworldbot
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
コード例 #5
0
ファイル: test_cipher.py プロジェクト: aelydens/teamworldbot
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
コード例 #6
0
ファイル: routes.py プロジェクト: aelydens/teamworldbot
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)
コード例 #7
0
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)
コード例 #8
0
def test_decryption_2():
    emojifier = emoji_it()
    assert emojifier.decrypt('🏫⛵ ! ?') == "um ! ?"
コード例 #9
0
def test_encryption_2():
    emojifier = emoji_it()
    assert emojifier.encrypt("um ! ?") == '🏫⛵ ! ?'
コード例 #10
0
ファイル: test_cipher.py プロジェクト: aelydens/teamworldbot
def test_default_sanity():
    cipher = emoji_it()

    assert cipher.emoji_key == ':rocket:'
    assert cipher.multiplier == 1
コード例 #11
0
def test_encryption_1():
    emojifier = emoji_it()
    assert emojifier.encrypt("hello") == '📍🐓😥😥🥪'
コード例 #12
0
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
コード例 #13
0
def test_numbers():
    emojifier = emoji_it()
    assert emojifier.encrypt("806-672-3455") == '⛷🤘🕡-🕡🕕🤘🏻-🤘🏾🤘🏼🤘🏽🤘🏽'
コード例 #14
0
def test_empty_input():
    emojifier = emoji_it()
    assert emojifier.encrypt('') == ''
コード例 #15
0
def test_chinese_korean():
    emojifier = emoji_it()
    assert emojifier.encrypt("漢字ㄲ, ㄸ, ㅃ, ㅆ, ㅉ") == '漢字ㄲ, ㄸ, ㅃ, ㅆ, ㅉ'
コード例 #16
0
ファイル: test_cipher.py プロジェクト: aelydens/teamworldbot
def test_default_sanity():
    cipher = emoji_it()

    assert cipher.emoji_key == ':rocket:'
    assert cipher.multiplier == 1
コード例 #17
0
def test_de_nonAlphabet_or_numbers():
    emojifier = emoji_it()
    assert emojifier.decrypt(
        "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
    ) == "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
コード例 #18
0
def test_decryption_1():
    emojifier = emoji_it()
    assert emojifier.decrypt('📍🐓😥😥🥪') == 'hello'
コード例 #19
0
def test_de_numbers():
    emojifier = emoji_it()
    assert emojifier.decrypt('⛷🤘🕡-🕡🕕🤘🏻-🤘🏾🤘🏼🤘🏽🤘🏽') == "806-672-3455"