Skip to content

Commit 48056a6

Browse files
committed
Adjusted devcontainer; added a test case for a variant query; included pytest-django plugin in the dev requirements
1 parent f776611 commit 48056a6

8 files changed

+106
-31
lines changed

.devcontainer/devcontainer.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
// The optional 'workspaceFolder' property is the path VS Code should open by default when
1919
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
20-
"workspaceFolder": "/workspace",
20+
"workspaceFolder": "/app",
2121

2222
// Set *default* container specific settings.json values on container create.
2323
"settings": {
24-
"python.analysis.extraPaths": [
25-
"${workspaceFolder}/svip_api"
26-
],
24+
// "python.analysis.extraPaths": [
25+
// "${workspaceFolder}/svip_api"
26+
// ],
2727
// "python.testing.unittestArgs": [
2828
// "-v",
2929
// "-s",
@@ -33,12 +33,11 @@
3333
// ],
3434
"python.testing.unittestEnabled": false,
3535
"python.testing.pytestArgs": [
36-
"./svip_api/api/tests/",
36+
"./api/tests/",
3737
"--exitfirst",
3838
"--verbose"
39-
] ,
39+
],
4040
"python.testing.pytestEnabled": true
41-
4241
},
4342

4443
// Add the IDs of extensions you want installed when the container is created.
@@ -64,7 +63,7 @@
6463

6564
// Uncomment the next line to run commands after the container is created - for example installing curl.
6665
// "postCreateCommand": "apt-get update && apt-get install -y curl",
67-
"postCreateCommand": "pip install -r ./svip_api/requirements.dev.txt"
66+
"postCreateCommand": "pip install -r ./requirements.dev.txt"
6867

6968
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
7069
// "remoteUser": "vscode"

.devcontainer/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ services:
2222

2323
volumes:
2424
# Update this to wherever you want VS Code to mount the folder of your project
25-
- .:/workspace:cached
25+
# - .:/workspace:cached
2626

2727
# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details.
28-
# - /var/run/docker.sock:/var/run/docker.sock
28+
- /var/run/docker.sock:/var/run/docker.sock
2929

3030
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
3131
# cap_add:

svip_api/.env.TEMPLATE

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Generated by Django 2.2.28 on 2022-08-12 13:39
2+
3+
from django.db import migrations, models
4+
import django_db_cascade.deletions
5+
import django_db_cascade.fields
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('api', '0161_merge_20220203_0937'),
12+
]
13+
14+
operations = [
15+
migrations.RemoveField(
16+
model_name='curationevidence',
17+
name='association',
18+
),
19+
migrations.RemoveField(
20+
model_name='curationentry',
21+
name='curation_evidences',
22+
),
23+
migrations.RemoveField(
24+
model_name='curationreview',
25+
name='curation_evidence',
26+
),
27+
migrations.RemoveField(
28+
model_name='revisedreview',
29+
name='curation_evidence',
30+
),
31+
migrations.AddField(
32+
model_name='revisedreview',
33+
name='curation_entry',
34+
field=django_db_cascade.fields.ForeignKey(null=True, on_delete=django_db_cascade.deletions.DB_CASCADE, related_name='revised_reviews', to='api.CurationEntry'),
35+
),
36+
migrations.AlterField(
37+
model_name='curationentry',
38+
name='variant',
39+
field=models.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, related_name='curation_entries', to='api.Variant'),
40+
),
41+
migrations.AlterField(
42+
model_name='curationreview',
43+
name='curation_entry',
44+
field=django_db_cascade.fields.ForeignKey(null=True, on_delete=django_db_cascade.deletions.DB_CASCADE, related_name='curation_reviews', to='api.CurationEntry'),
45+
),
46+
migrations.AlterField(
47+
model_name='sibannotation1',
48+
name='evidence',
49+
field=models.OneToOneField(on_delete=django_db_cascade.deletions.DB_CASCADE, related_name='annotation1', to='api.CurationEntry'),
50+
),
51+
migrations.AlterField(
52+
model_name='sibannotation2',
53+
name='evidence',
54+
field=models.OneToOneField(on_delete=django_db_cascade.deletions.DB_CASCADE, related_name='annotation2', to='api.CurationEntry'),
55+
),
56+
migrations.DeleteModel(
57+
name='CurationAssociation',
58+
),
59+
migrations.DeleteModel(
60+
name='CurationEvidence',
61+
),
62+
]

svip_api/api/pytest.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[pytest]
2-
DJANGO_SETTINGS_MODULE = svip_server.settings.development
3-
python_files = test_*.py
2+
DJANGO_SETTINGS_MODULE=svip_server.settings.development
3+
python_files=test_*.py

svip_api/api/tests/test_models.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from django.test import TestCase
22

33
class ModelTests(TestCase):
4-
def test_model_coice_class(self):
5-
""" Testing the Model Choice Class"""
4+
def test_model_choice_class(self):
5+
""" Testing the Model Choice Class """
66
from api.utils import ModelChoice
77
class MyModelChoice(ModelChoice):
88
prop1='Prop1'
@@ -13,3 +13,5 @@ class MyModelChoice(ModelChoice):
1313
('prop1', 'Prop1'),
1414
('prop2', 'Prop2')
1515
])
16+
17+

svip_api/api/tests/test_views.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
from django.test import TestCase
1+
from rest_framework.test import APITestCase
2+
from rest_framework import status
3+
from django.urls import reverse
4+
from api.models.genomic import Variant, Gene
25

6+
class ViewTests(APITestCase):
7+
def setUp(self):
8+
gene = Gene.objects.create(
9+
entrez_id=673,
10+
ensembl_gene_id='ENSG00000157764',
11+
symbol='BRAF'
12+
)
13+
variant = Variant.objects.create(
14+
gene=gene,
15+
name='V600E',
16+
description='BRAF V600E'
17+
)
18+
19+
def test_variant_list(self):
20+
""" Test the variant list """
21+
url = reverse('variant-list')
22+
response = self.client.get(url, format='json')
23+
self.assertEqual(response.status_code, status.HTTP_200_OK)
24+
25+
data = response.json()
26+
self.assertEqual(data['count'], 1, "We expect 1 result")
27+
self.assertEqual(data['results'][0]['name'], 'V600E', "We expenct the variant name to be 'V600E")
28+
29+

svip_api/requirements.dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# git+https://github.com/falquaddoomi/nplusone.git@24632de42d8c309d7181c02f1a93684ffc96567e#egg=nplusone-TrialSpark
44
# structlog==20.1.0
55
pytest==7.1.2
6+
pytest-django==4.5.2

0 commit comments

Comments
 (0)