-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from mskcc/develop
Develop
- Loading branch information
Showing
23 changed files
with
510 additions
and
51 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
language: python | ||
sudo: required | ||
os: | ||
- linux | ||
services: | ||
- postgresql | ||
addons: | ||
postgresql: "11" | ||
apt: | ||
packages: | ||
- postgresql-11 | ||
- postgresql-client-11 | ||
python: | ||
- "3.7.3" | ||
before_install: | ||
- sudo apt-get update | ||
- sudo apt-get --yes remove postgresql\* | ||
- sudo apt-get install -y postgresql-11 postgresql-client-11 | ||
- sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf | ||
- sudo service postgresql restart 11 | ||
install: | ||
- psql -p 5433 -c 'create database travis_ci_test;' -U postgres | ||
- pip install -r requirements.txt | ||
- pip install toil | ||
- source travis_env.sh | ||
- python manage.py migrate | ||
script: | ||
- source travis_env.sh | ||
- python manage.py test --verbosity=2 |
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
Django==2.2.10 | ||
Django==2.2.13 | ||
psycopg2==2.7.4 | ||
djangorestframework==3.9.4 | ||
markdown==3.1.1 | ||
django-filter==2.1.0 | ||
django-cors-headers==3.0.2 | ||
python-slugify==3.0.2 | ||
django-rest-swagger==2.2.0 | ||
drf-yasg==1.17.1 | ||
GitPython==3.0.8 | ||
celery==4.3.0 | ||
cwltool==2.0.20200122124526 | ||
schema-salad==5.0.20200122085940 | ||
psycopg2-binary==2.8.4 | ||
mock==4.0.2 |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__="1.2.0" |
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from mock import patch | ||
from django.urls import reverse | ||
from rest_framework import status | ||
from rest_framework.test import APITestCase | ||
from toil_orchestrator.models import Job, Status | ||
from django.contrib.auth.models import User | ||
from django.utils.timezone import now | ||
|
||
|
||
class JobTestCase(APITestCase): | ||
|
||
def setUp(self): | ||
example_app = {'github': {'repository':'example_repository','entrypoint':'example_entrypoint'}} | ||
self.example_job = Job.objects.create( | ||
app=example_app, | ||
root_dir='example_rootdir', | ||
id='7aacda86-b12f-4068-b2e3-a96552430a0f', | ||
job_store_location='/example_job_store') | ||
self.api_root = reverse('api-root') | ||
|
||
def test_list(self): | ||
url = self.api_root + 'jobs/' | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.json()['count'], 1) | ||
self.assertEqual(response.json()['results'][0]['id'], self.example_job.id) | ||
|
||
def test_read(self): | ||
url = '{}jobs/{}/'.format(self.api_root,self.example_job.id) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.json()['id'], self.example_job.id) | ||
|
||
def test_404_read(self): | ||
url = '{}jobs/{}/'.format(self.api_root,self.example_job.id[::-1]) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) | ||
|
||
@patch('toil_orchestrator.tasks.submit_jobs_to_lsf.delay') | ||
def test_create(self, submit_jobs_mock): | ||
url = self.api_root + 'jobs/' | ||
submit_jobs_mock.return_value = None | ||
data = { | ||
'app': self.example_job.app, | ||
'root_dir': self.example_job.root_dir, | ||
'inputs': {'example_input': True} | ||
} | ||
response = self.client.post(url, data=data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
|
||
def test_create_empty(self): | ||
url = self.api_root + 'jobs/' | ||
data = {} | ||
response = self.client.post(url, data=data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
def test_delete_unauthorized(self): | ||
url = '{}jobs/{}/'.format(self.api_root,self.example_job.id) | ||
response = self.client.delete(url) | ||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) | ||
|
||
def test_delete_authorized(self): | ||
url = '{}jobs/{}/'.format(self.api_root,self.example_job.id) | ||
admin_user = User.objects.create_superuser('admin', 'sample_email', 'password') | ||
self.client.force_authenticate(user=admin_user) | ||
response = self.client.delete(url) | ||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) | ||
|
||
@patch('toil_orchestrator.tasks.submit_jobs_to_lsf.delay') | ||
def test_resume(self, submit_jobs_mock): | ||
url = '{}jobs/{}/resume/'.format(self.api_root, self.example_job.id) | ||
submit_jobs_mock.return_value = None | ||
data = { | ||
'root_dir': self.example_job.root_dir | ||
} | ||
response = self.client.post(url, data=data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
self.assertEqual(response.json()['resume_job_store_location'], self.example_job.job_store_location) | ||
|
||
def test_resume_job_missing(self): | ||
url = '{}jobs/{}/resume/'.format(self.api_root,self.example_job.id[::-1]) | ||
data = { | ||
'root_dir': self.example_job.root_dir | ||
} | ||
response = self.client.post(url, data=data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) | ||
|
||
def test_resume_jobstore_cleaned_up(self): | ||
current_job = Job.objects.get(id=self.example_job.id) | ||
current_job.job_store_clean_up = now() | ||
current_job.save() | ||
url = '{}jobs/{}/resume/'.format(self.api_root,self.example_job.id) | ||
data = { | ||
'root_dir': self.example_job.root_dir | ||
} | ||
response = self.client.post(url, data=data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_410_GONE) | ||
|
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
Oops, something went wrong.