import pytest
from asterisksecurity.encryption import AsteriskEncrypt
from asterisksecurity.error import InvalidEncriptionKey

@pytest.fixture
def encryptor():
    return AsteriskEncrypt("myencryptionkey")

def test_encrypt_decrypt(encryptor):
    plaintext = "Hello, World!"
    encrypted = encryptor.encrypt(plaintext)
    decrypted = encryptor.decrypt(encrypted)
    assert decrypted == plaintext

def test_encrypt_decrypt_chinese(encryptor):
    plaintext = "你好，世界！"
    encrypted = encryptor.encrypt(plaintext)
    decrypted = encryptor.decrypt(encrypted)
    assert decrypted == plaintext

def test_invalid_key():
    invalid_key = "invalid-key"
    with pytest.raises(InvalidEncriptionKey):
        AsteriskEncrypt(invalid_key)
