-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update_job_status() now has option to ignore runtime errors (#51)
* update_job_status() now has option to ignore runtime errors * Updates based on CI failures * Updated CI config * Migrating CI off Python 2.x Migrating CI off Python 2.x to support latest change. Since latest change is straightforward, current operation using Python 2.7 should not be disrupted. * Updated CI configuration based on qp-klp plugin config. * bugfix * Recently renamed certs * Remove 3.11 from test matrix * Added script to add qiita root-ca to environment. Added script to add the root-ca used to sign Qiita's server.crt to qiita_client's environment. The functionality in this small script may be more useful if it becomes part of qiita_client itself. * Update PluginTestCase base class Update PluginTestCase base class to rely on standard environment to verify server credentials. Rely on new script to update standard environment. * Updated CI config to avoid installing extra plugins * Updates from testing * Add testing for 3.11 * Removed matrix testing for python 3.11 * test removal of pip updates * Test removal of some qiita installation commands * Updated based on discussions * test change * Removed unused config setting * Updates based on feedback
- Loading branch information
1 parent
d4e83b7
commit 21069c3
Showing
7 changed files
with
80 additions
and
40 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
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
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
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
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
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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# ----------------------------------------------------------------------------- | ||
|
||
from unittest import TestCase, main | ||
from os import environ, remove, close | ||
from os import remove, close, environ | ||
from os.path import basename, exists | ||
from tempfile import mkstemp | ||
from json import dumps | ||
|
@@ -19,6 +19,7 @@ | |
from qiita_client.exceptions import BadRequestError | ||
|
||
CLIENT_ID = '19ndkO3oMKsoChjVVWluF7QkxHRfYhTKSFbAVt8IhK7gZgDaO4' | ||
BAD_CLIENT_ID = 'NOT_A_CLIENT_ID' | ||
CLIENT_SECRET = ('J7FfQ7CQdOxuKhQAf1eoGgBAE81Ns8Gu3EKaWFm3IO2JKh' | ||
'AmmCWZuabe0O5Mp28s1') | ||
|
||
|
@@ -96,9 +97,12 @@ def test_format_payload_error(self): | |
|
||
class QiitaClientTests(PluginTestCase): | ||
def setUp(self): | ||
self.server_cert = environ.get('QIITA_SERVER_CERT', None) | ||
self.tester = QiitaClient("https://localhost:21174", CLIENT_ID, | ||
CLIENT_SECRET, server_cert=self.server_cert) | ||
self.tester = QiitaClient("https://localhost:21174", | ||
CLIENT_ID, | ||
CLIENT_SECRET) | ||
self.bad_tester = QiitaClient("https://localhost:21174", | ||
BAD_CLIENT_ID, | ||
CLIENT_SECRET) | ||
self.clean_up_files = [] | ||
|
||
# making assertRaisesRegex compatible with Python 2.7 and 3.9 | ||
|
@@ -111,12 +115,14 @@ def tearDown(self): | |
remove(fp) | ||
|
||
def test_init(self): | ||
obs = QiitaClient("https://localhost:21174", CLIENT_ID, | ||
CLIENT_SECRET, server_cert=self.server_cert) | ||
obs = QiitaClient("https://localhost:21174", | ||
CLIENT_ID, | ||
CLIENT_SECRET, | ||
ca_cert=environ['QIITA_ROOT_CA']) | ||
self.assertEqual(obs._server_url, "https://localhost:21174") | ||
self.assertEqual(obs._client_id, CLIENT_ID) | ||
self.assertEqual(obs._client_secret, CLIENT_SECRET) | ||
self.assertEqual(obs._verify, self.server_cert) | ||
self.assertEqual(obs._verify, environ['QIITA_ROOT_CA']) | ||
|
||
def test_get(self): | ||
obs = self.tester.get("/qiita_db/artifacts/1/") | ||
|
@@ -232,11 +238,36 @@ def test_update_job_step(self): | |
obs = self.tester.update_job_step(job_id, new_step) | ||
self.assertIsNone(obs) | ||
|
||
def test_update_job_step_ignore_failure(self): | ||
job_id = "bcc7ebcd-39c1-43e4-af2d-822e3589f14d" | ||
new_step = "some new step" | ||
|
||
# confirm that update_job_step behaves as before when ignore_error | ||
# parameter absent or set to False. | ||
|
||
with self.assertRaises(BaseException): | ||
self.bad_tester.update_job_step(job_id, new_step) | ||
|
||
with self.assertRaises(BaseException): | ||
self.bad_tester.update_job_step(job_id, | ||
new_step, | ||
ignore_error=False) | ||
|
||
# confirm that when ignore_error is set to True, an Error is NOT | ||
# raised. | ||
try: | ||
self.bad_tester.update_job_step(job_id, | ||
new_step, | ||
ignore_error=True) | ||
except BaseException as e: | ||
self.fail("update_job_step() raised an error: %s" % str(e)) | ||
|
||
def test_complete_job(self): | ||
# Create a new job | ||
data = { | ||
'user': '[email protected]', | ||
'command': dumps(['QIIME', '1.9.1', 'Pick closed-reference OTUs']), | ||
'command': dumps(['QIIMEq2', '1.9.1', | ||
'Pick closed-reference OTUs']), | ||
'status': 'running', | ||
'parameters': dumps({"reference": 1, | ||
"sortmerna_e_value": 1, | ||
|