|
@@ -212,7 +212,7 @@ class ClassifierTests(unittest.TestCase):
|
|
|
|
|
|
|
|
class HttpTests(unittest.IsolatedAsyncioTestCase):
|
|
class HttpTests(unittest.IsolatedAsyncioTestCase):
|
|
|
async def test_chat_payload_directly_accepted_and_invalid_rejected(self):
|
|
async def test_chat_payload_directly_accepted_and_invalid_rejected(self):
|
|
|
- runtime = Mock()
|
|
|
|
|
|
|
+ runtime = Mock(admission=None, talent_runtime=None)
|
|
|
runtime.classify_company = CompanyClassifier(Mock(return_value={'matches': []}))
|
|
runtime.classify_company = CompanyClassifier(Mock(return_value={'matches': []}))
|
|
|
app = create_app(Settings(), lambda _: runtime)
|
|
app = create_app(Settings(), lambda _: runtime)
|
|
|
async with app.router.lifespan_context(app):
|
|
async with app.router.lifespan_context(app):
|
|
@@ -228,7 +228,7 @@ class HttpTests(unittest.IsolatedAsyncioTestCase):
|
|
|
headers={'content-type': 'application/json'})).status_code, 413)
|
|
headers={'content-type': 'application/json'})).status_code, 413)
|
|
|
|
|
|
|
|
async def test_model_failure_not_empty_success(self):
|
|
async def test_model_failure_not_empty_success(self):
|
|
|
- runtime = Mock()
|
|
|
|
|
|
|
+ runtime = Mock(admission=None, talent_runtime=None)
|
|
|
runtime.classify_company = CompanyClassifier(Mock(side_effect=RuntimeError('SECRET')))
|
|
runtime.classify_company = CompanyClassifier(Mock(side_effect=RuntimeError('SECRET')))
|
|
|
app = create_app(Settings(), lambda _: runtime)
|
|
app = create_app(Settings(), lambda _: runtime)
|
|
|
async with app.router.lifespan_context(app):
|
|
async with app.router.lifespan_context(app):
|
|
@@ -244,7 +244,7 @@ class HttpTests(unittest.IsolatedAsyncioTestCase):
|
|
|
entered.set()
|
|
entered.set()
|
|
|
release.wait(5)
|
|
release.wait(5)
|
|
|
return CompanyClassifier(Mock(return_value={'matches': []}))(value)
|
|
return CompanyClassifier(Mock(return_value={'matches': []}))(value)
|
|
|
- runtime = Mock()
|
|
|
|
|
|
|
+ runtime = Mock(admission=None, talent_runtime=None)
|
|
|
runtime.classify_company = block
|
|
runtime.classify_company = block
|
|
|
app = create_app(Settings(max_concurrent=1), lambda _: runtime)
|
|
app = create_app(Settings(max_concurrent=1), lambda _: runtime)
|
|
|
try:
|
|
try:
|
|
@@ -266,7 +266,7 @@ class HttpTests(unittest.IsolatedAsyncioTestCase):
|
|
|
if data['category'] == '资质荣誉':
|
|
if data['category'] == '资质荣誉':
|
|
|
raise RuntimeError('SECRET')
|
|
raise RuntimeError('SECRET')
|
|
|
return {'matches': [matched()]} if data['category'] == '行业信息' else {'matches': []}
|
|
return {'matches': [matched()]} if data['category'] == '行业信息' else {'matches': []}
|
|
|
- runtime = Mock()
|
|
|
|
|
|
|
+ runtime = Mock(admission=None, talent_runtime=None)
|
|
|
runtime.classify_company = CompanyClassifier(model)
|
|
runtime.classify_company = CompanyClassifier(model)
|
|
|
app = create_app(Settings(), lambda _: runtime)
|
|
app = create_app(Settings(), lambda _: runtime)
|
|
|
async with app.router.lifespan_context(app):
|
|
async with app.router.lifespan_context(app):
|