def test_invalid_token(test_file_token):
    with open(test_file_path_token, "w") as token_file:
        token_file.write("InvalidToken")

    tranl_object = GoogleTranslate(test_file_path_token)
    with pytest.raises(requests.exceptions.HTTPError, match=r"401"):
        tranl_object.translate("Hello", "he")
def test_success_with_assert():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("hello", "he") == "שלום"
def test_success_no_assert():
    tranl_object = GoogleTranslate()
    tranl_object.translate("hello", "he")
def test_invalid_url():
    tranl_object = GoogleTranslate(GoogleTranslate.token_file_path,
                                   GoogleTranslate.translate_url + "_")
    with pytest.raises(requests.exceptions.HTTPError,
                       match="404 Client Error: Not Found for url"):
        tranl_object.translate("Hello", "he")
def test_empty_string():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("", "he", "en") == ""
def test_translate_string_given():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("hello", "he") == "שלום"
def test_translate_format_html_heb_to_eng():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("שלום", "en", None, "html") == "Hello"
def test_invalid_format():
    tranl_object = GoogleTranslate()
    with pytest.raises(requests.exceptions.HTTPError,
                       match="400 Client Error: Bad Request"):
        tranl_object.translate("Hello", "he", "en", "invalid_format")
def test_translate_source_explicit_heb_to_eng():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("שלום", "en", "he") == "Hello"
def test_translate_format_html_en_to_heb():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("hello", "he", None, "html") == "שלום"
def test_translate_source_explicit_en_to_heb():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("hello", "he", "en") == "שלום"
def test_translate_auto_detect_heb_to_eng():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("שלום", "en") == "Hello"
def test_translate_auto_detect_en_to_heb():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("hello", "he") == "שלום"
def test_translate_no_opt_params_heb_to_eng():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("שלום", "en", "he") == "Hello"
def test_translate_no_opt_params_en_to_heb():
    tranl_object = GoogleTranslate()
    assert tranl_object.translate("hello", "he", "en") == "שלום"