Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fixed webapi workspace manager tests, which now work on windows too
Browse files Browse the repository at this point in the history
  • Loading branch information
forman committed Apr 17, 2018
1 parent fdc579a commit d984f15
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/webapi/test_wsmanag.py
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)

0 comments on commit d984f15

Please sign in to comment.