Skip to content

Commit

Permalink
Updates for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alwx committed May 15, 2020
1 parent a9b10ba commit 0633b3d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ prepare-tests-windows: prepare-wget-windows prepare-tests-files
choco install graphviz

test: clean
# OMP_NUM_THREADS can improve overral performance using one thread by process (on tensorflow), avoiding overload
# OMP_NUM_THREADS can improve overrall performance using one thread by process (on tensorflow), avoiding overload
OMP_NUM_THREADS=1 poetry run pytest tests -n $(JOBS) --cov rasa

test-windows: clean
# OMP_NUM_THREADS can improve overral performance using one thread by process (on tensorflow), avoiding overload
# OMP_NUM_THREADS can improve overrall performance using one thread by process (on tensorflow), avoiding overload
OMP_NUM_THREADS=1 poetry run pytest tests -n $(JOBS) -m "not unix" --cov rasa

doctest: clean
Expand Down
2 changes: 1 addition & 1 deletion changelog/5784.misc.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Windows testing support.
Added testing of Rasa Open Source installations on Windows.
4 changes: 2 additions & 2 deletions tests/core/test_tracker_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from rasa.core.trackers import DialogueStateTracker
from rasa.utils.endpoints import EndpointConfig, read_endpoint_config
from tests.core.conftest import DEFAULT_ENDPOINTS_FILE, MockedMongoTrackerStore
from tests.utilities import write_file_config
import tests.utilities

domain = Domain.load("data/test_domains/default.yml")

Expand Down Expand Up @@ -357,7 +357,7 @@ def test_db_url_with_query_from_endpoint_config():
another: query
"""

filename = write_file_config(endpoint_config)
filename = tests.utilities.write_file_config(endpoint_config)
store_config = read_endpoint_config(filename, "tracker_store")
url = SQLTrackerStore.get_db_url(**store_config.kwargs)

Expand Down
4 changes: 2 additions & 2 deletions tests/nlu/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import ruamel.yaml as yaml

import pytest
import tests.utilities

from rasa.nlu.config import RasaNLUModelConfig
from rasa.nlu.components import ComponentBuilder
from rasa.utils.tensorflow.constants import EPOCHS, RANDOM_SEED
from tests.utilities import write_file_config

DEFAULT_DATA_PATH = "data/examples/rasa/demo-rasa.json"

Expand Down Expand Up @@ -41,7 +41,7 @@ def blank_config() -> RasaNLUModelConfig:

@pytest.fixture(scope="session")
def config_path() -> Text:
return write_file_config(
return tests.utilities.write_file_config(
yaml.safe_dump(
{
"language": "en",
Expand Down
10 changes: 5 additions & 5 deletions tests/nlu/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Text, List

import pytest
import tests.utilities

import rasa.utils.io as io_utils
from rasa.nlu.config import RasaNLUModelConfig
Expand All @@ -13,12 +14,11 @@
from rasa.nlu.constants import TRAINABLE_EXTRACTORS
from rasa.nlu.registry import registered_pipeline_templates
from rasa.nlu.model import Trainer
from tests.utilities import write_file_config


def test_blank_config(blank_config):
file_config = {}
filename = write_file_config(yaml.safe_dump(file_config))
filename = tests.utilities.write_file_config(yaml.safe_dump(file_config))
final_config = config.load(filename)

assert final_config.as_dict() == blank_config.as_dict()
Expand All @@ -27,15 +27,15 @@ def test_blank_config(blank_config):
def test_invalid_config_json():
file_config = """pipeline: [pretrained_embeddings_spacy""" # invalid yaml

filename = write_file_config(file_config)
filename = tests.utilities.write_file_config(file_config)

with pytest.raises(config.InvalidConfigError):
config.load(filename)


def test_invalid_pipeline_template():
args = {"pipeline": "my_made_up_name"}
filename = write_file_config(yaml.safe_dump(args))
filename = tests.utilities.write_file_config(yaml.safe_dump(args))

with pytest.raises(config.InvalidConfigError) as execinfo:
config.load(filename)
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_missing_property(pipeline_config):
@pytest.mark.unix
def test_pipeline_registry_lookup(pipeline_template: Text):
args = {"pipeline": pipeline_template}
filename = write_file_config(yaml.safe_dump(args))
filename = tests.utilities.write_file_config(yaml.safe_dump(args))

final_config = config.load(filename)
components = [c for c in final_config.pipeline]
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def write_temp_file(contents, suffix, mode="w+") -> Text:
return filename


def write_file_config(file_config) -> Text:
def write_file_config(file_config: Text) -> Text:
return write_temp_file(file_config, "_tmp_config_file.yml")


Expand Down

0 comments on commit 0633b3d

Please sign in to comment.