From d3c0970a0e1bb1826bb8bf2b4c5d71d7b732dcc3 Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Mon, 8 Aug 2022 20:19:25 +0200 Subject: [PATCH] [test][domain_middleware] tests for middleware --- tests/test_lib_domain_middlware.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_lib_domain_middlware.py b/tests/test_lib_domain_middlware.py index d4994b1..a2d291f 100644 --- a/tests/test_lib_domain_middlware.py +++ b/tests/test_lib_domain_middlware.py @@ -2,12 +2,23 @@ from starlette.testclient import TestClient from starlette.middleware.base import BaseHTTPMiddleware from unittest.mock import patch from halfapi.lib.domain_middleware import DomainMiddleware +from halfapi import __version__ def test_init(): with patch('starlette.middleware.base.BaseHTTPMiddleware.__init__') as init: - mw = DomainMiddleware('app', 'domain') + mw = DomainMiddleware('app', { + 'name': 'test', + 'id': 'randomid', + 'version': '0.0.0', + 'halfapi_version': __version__, + 'config': {} + }) init.assert_called_once_with('app') - assert mw.domain == 'domain' + assert isinstance(mw.domain, dict) + assert isinstance(mw.name, str) + assert mw.name == 'test' + assert isinstance(mw.config, dict) + assert len(mw.config) == 0 assert mw.request == None def test_call(application_debug):