This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed webapi workspace manager tests, which now work on windows too
- Loading branch information
Showing
1 changed file
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import os | ||
import sys | ||
import time | ||
import signal | ||
import unittest | ||
|
||
from cate.util.web.serviceinfo import read_service_info | ||
from cate.util.web.webapi import find_free_port, WebAPI | ||
from cate.webapi.wsmanag import WebAPIWorkspaceManager | ||
from test.core.test_wsmanag import WorkspaceManagerTestMixin | ||
|
||
_SERVICE_INFO_FILE = 'pytest-service-info.json' | ||
|
||
|
||
@unittest.skipIf(os.environ.get('CATE_DISABLE_WEB_TESTS', None) == '1', 'CATE_DISABLE_WEB_TESTS = 1') | ||
class WebAPIWorkspaceManagerTest(WorkspaceManagerTestMixin, unittest.TestCase): | ||
def setUp(self): | ||
self.port = find_free_port() | ||
WebAPI.start_subprocess('cate.webapi.start', port=self.port, caller='pytest') | ||
WebAPI.start_subprocess('cate.webapi.start', | ||
port=self.port, | ||
caller='pytest', | ||
service_info_file=_SERVICE_INFO_FILE) | ||
|
||
def tearDown(self): | ||
WebAPI.stop_subprocess('cate.webapi.stop', port=self.port, caller='pytest') | ||
if sys.platform == 'win32': | ||
# This helps getting around silly error raised inside Popen._internal_poll(): | ||
# OSError: [WinError 6] Das Handle ist ungültig | ||
time.sleep(5) | ||
service_info = read_service_info(_SERVICE_INFO_FILE) | ||
if service_info: | ||
os.kill(service_info['pid'], signal.SIGTERM) | ||
else: | ||
print("WebAPIWorkspaceManagerTest: error: can't find %s" % _SERVICE_INFO_FILE) | ||
|
||
def new_workspace_manager(self): | ||
return WebAPIWorkspaceManager(dict(port=self.port), rpc_timeout=2) |