File size: 853 Bytes
8241523
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from app import app


@pytest.fixture
def client():
app.config.update({"TESTING": True})
with app.test_client() as client:
yield client


def test_index_page(client):
resp = client.get("/")
assert resp.status_code == 200
assert b"Komoditas logam" in resp.data


def test_predict_invalid(client):
resp = client.post("/predict", data={"commodity": "unknownmetal"}, follow_redirects=True)
assert resp.status_code == 200
# Should flash an error message in Indonesian
assert b"Tidak menemukan simbol" in resp.data or b"Data historis" in resp.data


# Ensure templates only use ASCII in titles
import re


def test_ascii_titles():
with open("templates/base.html", "r", encoding="utf-8") as f:
html = f.read()
# Ensure no bullet character
assert "\u2022" not in html
# ======================= end tests/test_app.py ===============================