예제 #1
0
    def init_connection(self):
        os.environ["system_file"] = "./tests/testing_data/system.yaml"
        Utility.load_environment()
        connect(**Utility.mongoengine_connection(
            Utility.environment['database']["url"]))
        tmp_dir = tempfile.mkdtemp()
        pytest.tmp_dir = tmp_dir

        from rasa import train
        # model without entities
        train_result = train(
            domain='tests/testing_data/model_tester/domain.yml',
            config='tests/testing_data/model_tester/config.yml',
            training_files=[
                'tests/testing_data/model_tester/nlu_with_entities/nlu.yml',
                'tests/testing_data/model_tester/training_stories_success/stories.yml'
            ],
            output='tests/testing_data/model_tester/models',
            core_additional_arguments={"augmentation_factor": 100},
            force_training=True)
        pytest.model_path = train_result.model
        responses.add(
            'POST',
            Utility.environment["augmentation"]["paraphrase_url"],
            json={'data': {
                'paraphrases': ['common training example']
            }})
        responses.start()
        yield None
        responses.stop()
        shutil.rmtree(pytest.tmp_dir)
        shutil.rmtree('tests/testing_data/model_tester/models')
예제 #2
0
 def init(self):
     os.environ["system_file"] = "./tests/testing_data/system.yaml"
     Utility.load_environment()
     connect(**Utility.mongoengine_connection(Utility.environment['database']["url"]))
     tmp_dir = tempfile.mkdtemp()
     pytest.tmp_dir = tmp_dir
     yield None
     shutil.rmtree(tmp_dir)
예제 #3
0
    def init_connection(self):
        from rasa import train

        os.environ["system_file"] = "./tests/testing_data/system.yaml"
        Utility.load_environment()
        bot = 'agent_testing_user'
        pytest.bot = bot
        model_path = os.path.join('models', bot)
        os.mkdir(model_path)
        train(
            domain='tests/testing_data/model_tester/domain.yml',
            config='tests/testing_data/model_tester/config.yml',
            training_files=[
                'tests/testing_data/model_tester/nlu_with_entities/nlu.yml',
                'tests/testing_data/model_tester/training_stories_success/stories.yml'
            ],
            output=model_path,
            core_additional_arguments={"augmentation_factor": 100},
            force_training=True)
        yield None
        shutil.rmtree(model_path)
예제 #4
0
    def init(self):
        os.environ["system_file"] = "./tests/testing_data/system.yaml"
        Utility.load_environment()
        connect(**Utility.mongoengine_connection(Utility.environment['database']["url"]))
        tmp_dir = tempfile.mkdtemp()
        pytest.tmp_dir = tmp_dir

        from rasa import train
        # model without entities
        train_result = train(
            domain='tests/testing_data/model_tester/domain.yml',
            config='tests/testing_data/model_tester/config.yml',
            training_files=['tests/testing_data/model_tester/nlu_with_entities/nlu.yml',
                            'tests/testing_data/model_tester/training_stories_success/stories.yml'],
            output='tests/testing_data/model_tester/models',
            core_additional_arguments={"augmentation_factor": 100},
            force_training=True
        )
        pytest.model_path = train_result.model
        yield None
        shutil.rmtree(tmp_dir)
        shutil.rmtree('models/test_events_bot')
예제 #5
0
                        referrer=referrer,
                        permissions=permissions_value,
                        cache=cache_value,
                        content=content)

app = FastAPI()
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
    expose_headers=["content-disposition"],
)
app.add_middleware(GZipMiddleware)
Utility.load_environment()
apm_client = Utility.initiate_fastapi_apm_client()
if apm_client:
    app.add_middleware(ElasticAPM, client=apm_client)


@app.middleware("http")
async def add_secure_headers(request: Request, call_next):
    """Add security headers."""
    response = await call_next(request)
    secure_headers.framework.fastapi(response)
    return response


@app.middleware("http")
async def log_requests(request: Request, call_next):
예제 #6
0
 def init(self):
     os.environ["system_file"] = "./tests/testing_data/system.yaml"
     Utility.load_environment()
     connect(**Utility.mongoengine_connection(
         Utility.environment['database']["url"]))