|
3 | 3 | from typing import Text
|
4 | 4 |
|
5 | 5 | import pytest
|
| 6 | +from _pytest.capture import CaptureFixture |
6 | 7 | from _pytest.monkeypatch import MonkeyPatch
|
7 | 8 |
|
8 | 9 | import rasa.model
|
@@ -129,3 +130,38 @@ def test_train_nlu_temp_files(
|
129 | 130 | )
|
130 | 131 |
|
131 | 132 | assert count_temp_rasa_files(tempfile.tempdir) == 0
|
| 133 | + |
| 134 | + |
| 135 | +def test_train_nlu_wrong_format_error_message( |
| 136 | + capsys: CaptureFixture, |
| 137 | + tmp_path: Text, |
| 138 | + monkeypatch: MonkeyPatch, |
| 139 | + default_stack_config: Text, |
| 140 | + incorrect_nlu_data: Text, |
| 141 | +): |
| 142 | + monkeypatch.setattr(tempfile, "tempdir", tmp_path) |
| 143 | + |
| 144 | + train_nlu( |
| 145 | + default_stack_config, |
| 146 | + incorrect_nlu_data, |
| 147 | + output="test_train_nlu_temp_files_models", |
| 148 | + ) |
| 149 | + |
| 150 | + captured = capsys.readouterr() |
| 151 | + assert "Please verify the data format" in captured.out |
| 152 | + |
| 153 | + |
| 154 | +def test_train_nlu_no_nlu_file_error_message( |
| 155 | + capsys: CaptureFixture, |
| 156 | + tmp_path: Text, |
| 157 | + monkeypatch: MonkeyPatch, |
| 158 | + default_stack_config: Text, |
| 159 | +): |
| 160 | + monkeypatch.setattr(tempfile, "tempdir", tmp_path) |
| 161 | + |
| 162 | + train_nlu( |
| 163 | + default_stack_config, "", output="test_train_nlu_temp_files_models", |
| 164 | + ) |
| 165 | + |
| 166 | + captured = capsys.readouterr() |
| 167 | + assert "No NLU data given" in captured.out |
0 commit comments