|
1 | 1 | # Copyright (c) Microsoft Corporation. All rights reserved.
|
2 | 2 | # Licensed under the MIT License.
|
3 | 3 | import collections as col
|
4 |
| -import os |
5 |
| -from unittest.mock import patch |
6 | 4 |
|
7 | 5 | from azure_functions_worker import protos
|
8 | 6 | from tests.utils import testutils
|
|
19 | 17 |
|
20 | 18 | class TestInvalidAppStein(testutils.AsyncTestCase):
|
21 | 19 |
|
22 |
| - def setUp(self): |
23 |
| - self._ctrl = testutils.start_mockhost( |
24 |
| - script_root=STEIN_INVALID_APP_FUNCTIONS_DIR) |
25 |
| - self._pre_env = dict(os.environ) |
26 |
| - self.mock_version_info = patch( |
27 |
| - 'azure_functions_worker.dispatcher.sys.version_info', |
28 |
| - SysVersionInfo(3, 9, 0, 'final', 0)) |
29 |
| - self.mock_version_info.start() |
30 |
| - |
31 |
| - def tearDown(self): |
32 |
| - os.environ.clear() |
33 |
| - os.environ.update(self._pre_env) |
34 |
| - self.mock_version_info.stop() |
35 |
| - |
36 | 20 | async def test_indexing_not_app(self):
|
37 | 21 | """Test if the functions metadata response will be 0
|
38 | 22 | when an invalid app is provided
|
39 | 23 | """
|
40 |
| - async with self._ctrl as host: |
| 24 | + mock_host = testutils.start_mockhost( |
| 25 | + script_root=STEIN_INVALID_APP_FUNCTIONS_DIR) |
| 26 | + async with mock_host as host: |
41 | 27 | r = await host.get_functions_metadata()
|
42 | 28 | self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
|
43 | 29 | self.assertIn("Error", r.response.result.exception.message)
|
44 | 30 |
|
45 |
| - |
46 |
| -class TestInvalidStein(testutils.AsyncTestCase): |
47 |
| - |
48 |
| - def setUp(self): |
49 |
| - self._ctrl = testutils.start_mockhost( |
50 |
| - script_root=STEIN_INVALID_FUNCTIONS_DIR) |
51 |
| - self._pre_env = dict(os.environ) |
52 |
| - self.mock_version_info = patch( |
53 |
| - 'azure_functions_worker.dispatcher.sys.version_info', |
54 |
| - SysVersionInfo(3, 9, 0, 'final', 0)) |
55 |
| - self.mock_version_info.start() |
56 |
| - |
57 |
| - def tearDown(self): |
58 |
| - os.environ.clear() |
59 |
| - os.environ.update(self._pre_env) |
60 |
| - self.mock_version_info.stop() |
61 |
| - |
62 | 31 | async def test_indexing_invalid_app(self):
|
63 | 32 | """Test if the functions metadata response will be 0
|
64 | 33 | when an invalid app is provided
|
65 | 34 | """
|
66 |
| - async with self._ctrl as host: |
| 35 | + mock_host = testutils.start_mockhost( |
| 36 | + script_root=STEIN_INVALID_APP_FUNCTIONS_DIR) |
| 37 | + async with mock_host as host: |
67 | 38 | r = await host.get_functions_metadata()
|
68 | 39 | self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
|
69 | 40 | self.assertIn("Error", r.response.result.exception.message)
|
0 commit comments