Skip to content

Commit c23a3c5

Browse files
committed
Fix tests (and other stuff)
Signed-off-by: James Noss <[email protected]>
1 parent 0b48a7a commit c23a3c5

21 files changed

+92
-138
lines changed

biodb/apps/catalog/tests/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from catalog.models import Dataset
77
from uploader.tests.conftest import bio_sample_types, centers, instruments, mock_data_from_files, observables, \
8-
SimpleQueryFactory, spectra_measurement_types, sql_views, mock_data # noqa: F401
8+
SimpleQueryFactory, array_measurement_types, sql_views, mock_data # noqa: F401
99
from user.models import Center as UserCenter
1010

1111

@@ -23,7 +23,7 @@ def staffuser(centers): # noqa: F811
2323
return User.objects.create(username="staff",
2424
2525
password="secret",
26-
center=UserCenter.objects.get(name="jhu"),
26+
center=UserCenter.objects.get(name="JHU"),
2727
is_staff=True,
2828
is_superuser=False)
2929

@@ -33,7 +33,7 @@ def cataloguser(centers): # noqa: F811
3333
return User.objects.create(username="analyst",
3434
3535
password="secret",
36-
center=UserCenter.objects.get(name="jhu"),
36+
center=UserCenter.objects.get(name="JHU"),
3737
is_staff=True,
3838
is_superuser=False,
3939
is_catalogviewer=True)
@@ -44,7 +44,7 @@ def superuser(centers): # noqa: F811
4444
return User.objects.create(username="admin",
4545
4646
password="secret",
47-
center=UserCenter.objects.get(name="jhu"),
47+
center=UserCenter.objects.get(name="JHU"),
4848
is_staff=True,
4949
is_superuser=True)
5050

biodb/apps/uploader/admin.py

-24
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,6 @@ class InstrumentAdmin(RestrictedByCenterMixin, ModelAdmin):
163163
"center"]
164164
}
165165
),
166-
(
167-
"Spectrometer",
168-
{
169-
"fields": ["spectrometer_manufacturer", "spectrometer_model", "spectrometer_serial_number"],
170-
}
171-
),
172-
(
173-
"Laser",
174-
{
175-
"fields": ["laser_manufacturer", "laser_model", "laser_serial_number"],
176-
}
177-
),
178166
(
179167
"More Details",
180168
{
@@ -468,8 +456,6 @@ class ArrayDataMixin:
468456
{
469457
"fields": ["measurement_id",
470458
"measurement_type",
471-
"atr_crystal",
472-
"n_coadditions",
473459
"acquisition_time",
474460
"resolution",
475461
"power",
@@ -479,16 +465,6 @@ class ArrayDataMixin:
479465
"date"],
480466
}
481467
),
482-
(
483-
"SERS Details",
484-
{
485-
"classes": ["collapse"],
486-
"fields": ["sers_description",
487-
"sers_particle_material",
488-
"sers_particle_size",
489-
"sers_particle_concentration"],
490-
}
491-
),
492468
(
493469
"More Details",
494470
{

biodb/apps/uploader/fixtures/spectrameasurementtypes.json biodb/apps/uploader/fixtures/arraymeasurementtypes.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[
22
{
3-
"model": "uploader.SpectraMeasurementType",
3+
"model": "uploader.ArrayMeasurementType",
44
"pk": 1,
55
"fields": {
6-
"name": "atr-ftir",
6+
"name": "magic",
77
"created_at": "2013-09-06T00:00:00+00:00",
88
"updated_at": "2013-09-06T00:00:00+00:00"
99
}

biodb/apps/uploader/fixtures/instruments.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
"pk": "4205d8ac-90c1-4529-90b2-6751f665c403",
55
"fields": {
66
"cid": "",
7-
"manufacturer": "Agilent",
8-
"model": "Cary 630",
7+
"manufacturer": "JHU",
8+
"model": "Analyzer1000",
99
"serial_number": "",
10-
"spectrometer_manufacturer": "",
11-
"spectrometer_model": "",
12-
"spectrometer_serial_number": "",
13-
"laser_manufacturer": "",
14-
"laser_model": "",
15-
"laser_serial_number": "",
1610
"created_at": "2013-09-06T00:00:00+00:00",
1711
"updated_at": "2013-09-06T00:00:00+00:00"
1812
}

biodb/apps/uploader/fixtures/qcannotators.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"fields": {
66
"name": "sum",
77
"fully_qualified_class_name": "biodb.qc.qcfilter.QcSum",
8-
"description": "Sum of the spectral data (total flux)",
8+
"description": "Sum of the array data (total flux)",
99
"default": true,
1010
"value_type": "FLOAT",
1111
"created_at": "2013-09-06T00:00:00+00:00",

biodb/apps/uploader/fixtures/test_data.json

+24-40
Original file line numberDiff line numberDiff line change
@@ -3175,15 +3175,9 @@
31753175
"pk": "4205d8ac-90c1-4529-90b2-6751f665c403",
31763176
"fields": {
31773177
"cid": "",
3178-
"manufacturer": "Agilent",
3179-
"model": "Cary 630",
3178+
"manufacturer": "JHU",
3179+
"model": "Analyzer1000",
31803180
"serial_number": "",
3181-
"spectrometer_manufacturer": "",
3182-
"spectrometer_model": "",
3183-
"spectrometer_serial_number": "",
3184-
"laser_manufacturer": "",
3185-
"laser_model": "",
3186-
"laser_serial_number": "",
31873181
"created_at": "2013-09-06T00:00:00+00:00",
31883182
"updated_at": "2013-09-06T00:00:00+00:00"
31893183
}
@@ -3328,16 +3322,16 @@
33283322
}
33293323
},
33303324
{
3331-
"model": "uploader.spectrameasurementtype",
3325+
"model": "uploader.arraymeasurementtype",
33323326
"pk": 1,
33333327
"fields": {
3334-
"name": "atr-ftir",
3328+
"name": "magic",
33353329
"created_at": "2013-09-06T00:00:00+00:00",
33363330
"updated_at": "2013-09-06T00:00:00+00:00"
33373331
}
33383332
},
33393333
{
3340-
"model": "uploader.spectraldata",
3334+
"model": "uploader.arraydata",
33413335
"pk": 1117,
33423336
"fields": {
33433337
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3346,13 +3340,12 @@
33463340
"bio_sample": 1117,
33473341
"measurement_type": 1,
33483342
"acquisition_time": null,
3349-
"n_coadditions": 32,
33503343
"resolution": null,
3351-
"data": "spectral_data/class_uploader.models_7GOLfEP.csv"
3344+
"data": "array_data/class_uploader.models_7GOLfEP.csv"
33523345
}
33533346
},
33543347
{
3355-
"model": "uploader.spectraldata",
3348+
"model": "uploader.arraydata",
33563349
"pk": 1118,
33573350
"fields": {
33583351
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3361,13 +3354,12 @@
33613354
"bio_sample": 1118,
33623355
"measurement_type": 1,
33633356
"acquisition_time": null,
3364-
"n_coadditions": 32,
33653357
"resolution": null,
3366-
"data": "spectral_data/class_uploader.models_02z3Zqt.csv"
3358+
"data": "array_data/class_uploader.models_02z3Zqt.csv"
33673359
}
33683360
},
33693361
{
3370-
"model": "uploader.spectraldata",
3362+
"model": "uploader.arraydata",
33713363
"pk": 1119,
33723364
"fields": {
33733365
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3376,13 +3368,12 @@
33763368
"bio_sample": 1119,
33773369
"measurement_type": 1,
33783370
"acquisition_time": null,
3379-
"n_coadditions": 32,
33803371
"resolution": null,
3381-
"data": "spectral_data/class_uploader.models_y6CI6Qs.csv"
3372+
"data": "array_data/class_uploader.models_y6CI6Qs.csv"
33823373
}
33833374
},
33843375
{
3385-
"model": "uploader.spectraldata",
3376+
"model": "uploader.arraydata",
33863377
"pk": 1120,
33873378
"fields": {
33883379
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3391,13 +3382,12 @@
33913382
"bio_sample": 1120,
33923383
"measurement_type": 1,
33933384
"acquisition_time": null,
3394-
"n_coadditions": 32,
33953385
"resolution": null,
3396-
"data": "spectral_data/class_uploader.models_8bK4evK.csv"
3386+
"data": "array_data/class_uploader.models_8bK4evK.csv"
33973387
}
33983388
},
33993389
{
3400-
"model": "uploader.spectraldata",
3390+
"model": "uploader.arraydata",
34013391
"pk": 1121,
34023392
"fields": {
34033393
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3406,13 +3396,12 @@
34063396
"bio_sample": 1121,
34073397
"measurement_type": 1,
34083398
"acquisition_time": null,
3409-
"n_coadditions": 32,
34103399
"resolution": null,
3411-
"data": "spectral_data/class_uploader.models_83JcnDj.csv"
3400+
"data": "array_data/class_uploader.models_83JcnDj.csv"
34123401
}
34133402
},
34143403
{
3415-
"model": "uploader.spectraldata",
3404+
"model": "uploader.arraydata",
34163405
"pk": 1122,
34173406
"fields": {
34183407
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3421,13 +3410,12 @@
34213410
"bio_sample": 1122,
34223411
"measurement_type": 1,
34233412
"acquisition_time": null,
3424-
"n_coadditions": 32,
34253413
"resolution": null,
3426-
"data": "spectral_data/class_uploader.models_oTQYhIJ.csv"
3414+
"data": "array_data/class_uploader.models_oTQYhIJ.csv"
34273415
}
34283416
},
34293417
{
3430-
"model": "uploader.spectraldata",
3418+
"model": "uploader.arraydata",
34313419
"pk": 1123,
34323420
"fields": {
34333421
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3436,13 +3424,12 @@
34363424
"bio_sample": 1123,
34373425
"measurement_type": 1,
34383426
"acquisition_time": null,
3439-
"n_coadditions": 32,
34403427
"resolution": null,
3441-
"data": "spectral_data/class_uploader.models_n8JSA1k.csv"
3428+
"data": "array_data/class_uploader.models_n8JSA1k.csv"
34423429
}
34433430
},
34443431
{
3445-
"model": "uploader.spectraldata",
3432+
"model": "uploader.arraydata",
34463433
"pk": 1124,
34473434
"fields": {
34483435
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3451,13 +3438,12 @@
34513438
"bio_sample": 1124,
34523439
"measurement_type": 1,
34533440
"acquisition_time": null,
3454-
"n_coadditions": 32,
34553441
"resolution": null,
3456-
"data": "spectral_data/class_uploader.models_xsCNQjJ.csv"
3442+
"data": "array_data/class_uploader.models_xsCNQjJ.csv"
34573443
}
34583444
},
34593445
{
3460-
"model": "uploader.spectraldata",
3446+
"model": "uploader.arraydata",
34613447
"pk": 1125,
34623448
"fields": {
34633449
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3466,13 +3452,12 @@
34663452
"bio_sample": 1125,
34673453
"measurement_type": 1,
34683454
"acquisition_time": null,
3469-
"n_coadditions": 32,
34703455
"resolution": null,
3471-
"data": "spectral_data/class_uploader.models_QkF6GzX.csv"
3456+
"data": "array_data/class_uploader.models_QkF6GzX.csv"
34723457
}
34733458
},
34743459
{
3475-
"model": "uploader.spectraldata",
3460+
"model": "uploader.arraydata",
34763461
"pk": 1126,
34773462
"fields": {
34783463
"created_at": "2013-09-06T00:00:00+00:00",
@@ -3481,9 +3466,8 @@
34813466
"bio_sample": 1126,
34823467
"measurement_type": 1,
34833468
"acquisition_time": null,
3484-
"n_coadditions": 32,
34853469
"resolution": null,
3486-
"data": "spectral_data/class_uploader.models_qrNWV5h.csv"
3470+
"data": "array_data/class_uploader.models_qrNWV5h.csv"
34873471
}
34883472
}
34893473
]

biodb/apps/uploader/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.11 on 2024-05-30 01:49
1+
# Generated by Django 4.2.11 on 2024-05-30 02:14
22

33
import django.core.validators
44
from django.db import migrations, models

biodb/apps/uploader/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ def annotate(self, annotator=None, force=False) -> list:
868868
return
869869
annotation = self.qc_annotation.get(annotator=annotator)
870870
else:
871-
annotation = QCAnnotation(annotator=annotator, arary_data=self)
871+
annotation = QCAnnotation(annotator=annotator, array_data=self)
872872
return [annotation.run()]
873873

874874
annotations = []
@@ -1042,7 +1042,7 @@ def sql(cls):
10421042
join bio_sample bs on bs.visit_id=v.id
10431043
join bio_sample_type bst on bst.id=bs.sample_type_id
10441044
join array_data sd on sd.bio_sample_id=bs.id
1045-
join spectra_measurement_type smt on smt.id=sd.measurement_type_id
1045+
join array_measurement_type smt on smt.id=sd.measurement_type_id
10461046
join instrument i on i.id=sd.instrument_id
10471047
left outer join v_visit_observations vs on vs.visit_id=v.id
10481048
""" # nosec B608

biodb/apps/uploader/tests/conftest.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Meta:
7979
def django_request(center):
8080
request = RequestFactory()
8181
user = UserFactory()
82-
user.center = UserCenter.objects.get(name="jhu")
82+
user.center = UserCenter.objects.get(name="JHU")
8383
request.user = user
8484
return request
8585

@@ -93,7 +93,7 @@ def centers(django_db_blocker):
9393

9494
@pytest.fixture(scope="function")
9595
def center(centers):
96-
return Center.objects.get(name="jhu")
96+
return Center.objects.get(name="JHU")
9797

9898

9999
@pytest.fixture(scope="function")
@@ -109,9 +109,9 @@ def bio_sample_types(django_db_blocker):
109109

110110

111111
@pytest.fixture(scope="function")
112-
def spectra_measurement_types(django_db_blocker):
112+
def array_measurement_types(django_db_blocker):
113113
with django_db_blocker.unblock():
114-
call_command('loaddata', "--database=bsr", 'spectrameasurementtypes.json')
114+
call_command('loaddata', "--database=bsr", 'arraymeasurementtypes.json')
115115

116116

117117
@pytest.fixture(scope="function")
@@ -163,7 +163,7 @@ def bulk_upload():
163163
name=meta_data_path.name),
164164
array_data_file=django.core.files.File(array_data,
165165
name=array_file_path.name),
166-
center=Center.objects.get(name="jhu"))
166+
center=Center.objects.get(name="JHU"))
167167
data_upload.clean()
168168
data_upload.save()
169169

@@ -177,7 +177,7 @@ def mock_data_from_files(request,
177177
django_db_blocker,
178178
instruments,
179179
bio_sample_types,
180-
spectra_measurement_types):
180+
array_measurement_types):
181181
# patch MEDIA_ROOT
182182
media_root = request.node.get_closest_marker("media_root")
183183
if media_root:

0 commit comments

Comments
 (0)