|
1 | 1 | from app.db.model import IonChannelModel |
| 2 | +from app.schemas.morphology import ReconstructionMorphologyRead |
2 | 3 |
|
3 | 4 | from .utils import ( |
4 | 5 | PROJECT_ID, |
|
11 | 12 | ROUTE = "/entity" |
12 | 13 |
|
13 | 14 |
|
| 15 | +def test_get_entity(client, brain_region_id, species_id, strain_id, license_id): |
| 16 | + morph = assert_request( |
| 17 | + client.post, |
| 18 | + url="/reconstruction-morphology", |
| 19 | + json={ |
| 20 | + "brain_region_id": str(brain_region_id), |
| 21 | + "species_id": str(species_id), |
| 22 | + "strain_id": str(strain_id), |
| 23 | + "description": "Test morph", |
| 24 | + "name": "Test morph", |
| 25 | + "location": {"x": 10, "y": 20, "z": 30}, |
| 26 | + "legacy_id": ["Test Legacy ID"], |
| 27 | + "license_id": str(license_id), |
| 28 | + }, |
| 29 | + ).json() |
| 30 | + |
| 31 | + data = assert_request(client.get, url=f"{ROUTE}/{morph['id']}").json() |
| 32 | + |
| 33 | + assert data["type"] == "reconstruction_morphology" |
| 34 | + |
| 35 | + |
| 36 | +def test_get_entity_no_auth( |
| 37 | + client, client_user_2, brain_region_id, species_id, strain_id, license_id |
| 38 | +): |
| 39 | + morph = assert_request( |
| 40 | + client_user_2.post, |
| 41 | + url="/reconstruction-morphology", |
| 42 | + json={ |
| 43 | + "brain_region_id": str(brain_region_id), |
| 44 | + "species_id": str(species_id), |
| 45 | + "strain_id": str(strain_id), |
| 46 | + "description": "Test morph", |
| 47 | + "name": "Test morph", |
| 48 | + "location": {"x": 10, "y": 20, "z": 30}, |
| 49 | + "legacy_id": ["Test Legacy ID"], |
| 50 | + "license_id": str(license_id), |
| 51 | + }, |
| 52 | + ).json() |
| 53 | + |
| 54 | + res = client.get(url=f"{ROUTE}/{morph['id']}") |
| 55 | + |
| 56 | + assert res.status_code == 404 |
| 57 | + |
| 58 | + |
| 59 | +def test_public_unrelated_project_accessible( |
| 60 | + client, client_user_2, brain_region_id, species_id, strain_id, license_id |
| 61 | +): |
| 62 | + morph = assert_request( |
| 63 | + client_user_2.post, |
| 64 | + url="/reconstruction-morphology", |
| 65 | + json={ |
| 66 | + "authorized_public": True, |
| 67 | + "brain_region_id": str(brain_region_id), |
| 68 | + "species_id": str(species_id), |
| 69 | + "strain_id": str(strain_id), |
| 70 | + "description": "Test morph", |
| 71 | + "name": "Test morph", |
| 72 | + "location": {"x": 10, "y": 20, "z": 30}, |
| 73 | + "legacy_id": ["Test Legacy ID"], |
| 74 | + "license_id": str(license_id), |
| 75 | + }, |
| 76 | + ).json() |
| 77 | + |
| 78 | + data = assert_request(client.get, url=f"{ROUTE}/{morph['id']}").json() |
| 79 | + assert data["type"] == "reconstruction_morphology" |
| 80 | + |
| 81 | + morph_detail = assert_request( |
| 82 | + client.get, url=f"/reconstruction-morphology/{morph['id']}" |
| 83 | + ).json() |
| 84 | + |
| 85 | + assert ReconstructionMorphologyRead.model_validate(morph_detail) |
| 86 | + |
| 87 | + |
14 | 88 | def test_count_entities_validation_errors(client): |
15 | 89 | """Test validation errors for the count endpoint.""" |
16 | 90 | response = client.get(f"{ROUTE}/counts") |
|
0 commit comments