-
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.
Add regression test for cycledash.views.examine bug
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 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,57 @@ | ||
"""Test rendered views of Cycledash.""" | ||
import mock | ||
import nose | ||
import nose.tools as asserts | ||
|
||
from cycledash import app, db | ||
from common.helpers import tables | ||
import cycledash.views | ||
|
||
|
||
from test_projects_api import create_project_with_name | ||
from test_bams_api import create_bam_with_name | ||
|
||
|
||
PROJECT_NAME = 'Testing' | ||
mocked = mock.MagicMock() | ||
|
||
|
||
class TestViews(object): | ||
|
||
def setUp(self): | ||
self.ctx = app.test_request_context() | ||
self.ctx.push() | ||
project = create_project_with_name(PROJECT_NAME) | ||
self.normal_bam = create_bam_with_name(project['id'], 'normal', | ||
uri='/bam/path/normal.bam') | ||
self.tumor_bam = create_bam_with_name(project['id'], 'tumor', | ||
uri='/bam/path/tumor.bam') | ||
with tables(db.engine, 'vcfs') as (con, runs): | ||
res = runs.insert( | ||
{'uri': 'file://path/to/something.vcf', 'project_id': project['id'], | ||
'normal_bam_id': self.normal_bam['id'], | ||
'tumor_bam_id': self.tumor_bam['id'], | ||
'vcf_header': ''} | ||
).returning(*runs.c).execute() | ||
self.run = dict(res.fetchone()) | ||
|
||
def tearDown(self): | ||
with tables(db.engine, 'projects', 'bams', 'vcfs') as (con, projects, bams, runs): | ||
runs.delete().execute() | ||
bams.delete().execute() | ||
projects.delete().execute() | ||
self.ctx.pop() | ||
|
||
@mock.patch('cycledash.views.render_template', mocked) | ||
@mock.patch('cycledash.genotypes') | ||
def test_examine(self, *mocks): | ||
res = cycledash.views.examine(self.run['id']) | ||
vcf = mocked.call_args[1]['vcf'] | ||
asserts.eq_(vcf['id'], self.run['id']) | ||
asserts.eq_(vcf['normal_bam']['id'], self.normal_bam['id']) | ||
asserts.eq_(vcf['tumor_bam']['id'], self.tumor_bam['id']) | ||
asserts.eq_(vcf['normal_bam']['uri'], self.normal_bam['uri']) | ||
asserts.eq_(vcf['tumor_bam']['uri'], self.tumor_bam['uri']) | ||
asserts.eq_(vcf['normal_bam']['name'], self.normal_bam['name']) | ||
asserts.eq_(vcf['tumor_bam']['name'], self.tumor_bam['name']) | ||
|