|
1 | 1 | from unittest.mock import MagicMock |
2 | 2 |
|
| 3 | +import pytest |
| 4 | + |
3 | 5 | from ingredient_parser import parse_ingredient |
4 | 6 | from ingredient_parser.en.parser import guess_ingredient_name |
5 | 7 |
|
6 | 8 |
|
7 | 9 | class Test_expect_name_in_output: |
| 10 | + @pytest.mark.model_dependent |
8 | 11 | def test_enabled(self): |
9 | 12 | """ |
10 | 13 | Test that the return name is not [] |
11 | 14 | """ |
12 | | - sentence = "1 can (14 fluid ounces, or 425 ml) coconut milk" |
| 15 | + sentence = "1 cup, plus 2 tablespoons olive oil" |
13 | 16 | parsed = parse_ingredient(sentence, expect_name_in_output=True) |
14 | 17 | assert parsed.name != [] |
15 | 18 |
|
| 19 | + @pytest.mark.model_dependent |
16 | 20 | def test_disabled(self): |
17 | 21 | """ |
18 | 22 | Test that the returned name is [] |
19 | 23 | """ |
20 | | - sentence = "1 can (14 fluid ounces, or 425 ml) coconut milk" |
| 24 | + sentence = "1 cup, plus 2 tablespoons olive oil" |
21 | 25 | parsed = parse_ingredient(sentence, expect_name_in_output=False) |
22 | 26 | assert parsed.name == [] |
23 | 27 |
|
| 28 | + @pytest.mark.model_dependent |
24 | 29 | def test_disabled_name_not_separate(self): |
25 | 30 | """ |
26 | 31 | Test that the returned name is [] when not separating names |
27 | 32 | """ |
28 | | - sentence = "1 can (14 fluid ounces, or 425 ml) coconut milk" |
| 33 | + sentence = "1 cup, plus 2 tablespoons olive oil" |
29 | 34 | parsed = parse_ingredient( |
30 | 35 | sentence, expect_name_in_output=False, separate_names=False |
31 | 36 | ) |
32 | 37 | assert parsed.name == [] |
33 | 38 |
|
| 39 | + @pytest.mark.model_dependent |
34 | 40 | def test_enabled_but_no_name(self): |
35 | 41 | """ |
36 | 42 | Test that the return name is None even though guess_name_fallback is enabled. |
|
0 commit comments