39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
import pytest
|
|
|
|
from app.categories import classify, suggest_subcategory
|
|
from app.domain import Category
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("description", "category"),
|
|
[
|
|
("ярче", Category.PRODUCTS),
|
|
("Пиво и снеки", Category.PRODUCTS),
|
|
("бензин газпромнефть", Category.CAR),
|
|
("платёж по ипотеке", Category.CREDITS),
|
|
("билеты в кино", Category.ENTERTAINMENT),
|
|
("обои в спальню", Category.RENOVATION),
|
|
("5000 ремонт", Category.RENOVATION),
|
|
("ремонт машины", Category.CAR),
|
|
("подарок коллеге", Category.OTHER),
|
|
],
|
|
)
|
|
def test_classification(description, category):
|
|
assert classify(description) is category
|
|
|
|
|
|
def test_keyword_does_not_match_inside_another_word():
|
|
assert classify("корм для барсика") is Category.OTHER
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("description", "category", "subcategory"),
|
|
[
|
|
("3000 бензин", Category.CAR, "car_fuel"),
|
|
("запчасти на машину", Category.CAR, "car_parts"),
|
|
("пиво", Category.PRODUCTS, "products_alcohol"),
|
|
("кофе в кафе", Category.PRODUCTS, "products_cafe"),
|
|
],
|
|
)
|
|
def test_subcategory_suggestion(description, category, subcategory):
|
|
assert suggest_subcategory(category, description) == subcategory
|