#!/usr/bin/env python3 """Quick checks for capitalization-based term detection.""" from __future__ import annotations import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) from azure_vi_glossary import extract_capitalized_terms, improve_bilingual def test_extract() -> None: en = ( "You should assign the Storage Account Key Operator Service Role. " "Standard SKU Azure container registry named ContReg1. " "Upgrade the Premium SKU." ) terms = extract_capitalized_terms(en) assert any("Storage Account Key" in t for t in terms), terms assert any("Standard SKU" in t for t in terms), terms assert any("container registry" in t.lower() for t in terms), terms def test_improve_q250() -> None: en = ( "You have an Azure subscription that contains a Standard SKU Azure " "container registry named ContReg1." ) vi = ( "Bạn có Azure subscription chứa sổ đăng ký vùng chứa SKU Azure tiêu chuẩn " "có tên ContReg1." ) out = improve_bilingual(en, vi) or "" assert "Standard SKU Azure container registry" in out, out assert "sổ đăng ký" not in out, out def test_improve_role() -> None: en = "assign the Storage Account Key Operator Service Role1." vi = "gán Khóa storage account Vai trò dịch vụ của nhà điều hành1." out = improve_bilingual(en, vi) or "" assert "Storage Account Key Operator Service Role" in out, out def test_improve_az305_access_review() -> None: en = "create an access review of Application1." vi = "tạo bản đánh giá quyền truy cập của Application1." out = improve_bilingual(en, vi) or "" assert "access review" in out, out assert "bản đánh giá" not in out, out def test_improve_az305_runbook() -> None: en = "Create an Azure Automation runbook that runs the Get-AzRoleAssignment cmdlet." vi = "Tạo sổ tay chạy Azure Automation chạy lệnh ghép ngắn Get-AzRoleAssignment." out = improve_bilingual(en, vi) or "" assert "runbook" in out, out assert "sổ tay" not in out, out assert "lệnh ghép ngắn" not in out, out if __name__ == "__main__": test_extract() test_improve_q250() test_improve_role() test_improve_az305_access_review() test_improve_az305_runbook() print("ok")