Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Mar 31, 2023
1 parent 720abd9 commit 985c8a9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
34 changes: 17 additions & 17 deletions fixtures/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pk": 1,
"fields": {
"title": "ISIMIP simulation round",
"attribute": "simulation_round",
"identifier": "simulation_round",
"order": 1
}
},
Expand All @@ -13,7 +13,7 @@
"pk": 2,
"fields": {
"title": "Data product",
"attribute": "product",
"identifier": "product",
"order": 2
}
},
Expand All @@ -22,7 +22,7 @@
"pk": 3,
"fields": {
"title": "Input category",
"attribute": "category",
"identifier": "category",
"order": 14
}
},
Expand All @@ -31,7 +31,7 @@
"pk": 5,
"fields": {
"title": "Climate scenario",
"attribute": "climate_scenario",
"identifier": "climate_scenario",
"order": 8
}
},
Expand All @@ -40,7 +40,7 @@
"pk": 8,
"fields": {
"title": "Climate forcing",
"attribute": "climate_forcing",
"identifier": "climate_forcing",
"order": 7
}
},
Expand All @@ -49,7 +49,7 @@
"pk": 18,
"fields": {
"title": "Climate variable",
"attribute": "climate_variable",
"identifier": "climate_variable",
"order": 17
}
},
Expand All @@ -58,7 +58,7 @@
"pk": 19,
"fields": {
"title": "Input subcategory",
"attribute": "subcategory",
"identifier": "subcategory",
"order": 15
}
},
Expand All @@ -67,7 +67,7 @@
"pk": 20,
"fields": {
"title": "Socio-economic scenario",
"attribute": "soc_scenario",
"identifier": "soc_scenario",
"order": 9
}
},
Expand All @@ -76,7 +76,7 @@
"pk": 21,
"fields": {
"title": "Socio-economic dataset",
"attribute": "soc_dataset",
"identifier": "soc_dataset",
"order": 16
}
},
Expand All @@ -85,7 +85,7 @@
"pk": 22,
"fields": {
"title": "Geographic dataset",
"attribute": "geo_dataset",
"identifier": "geo_dataset",
"order": 18
}
},
Expand All @@ -94,7 +94,7 @@
"pk": 23,
"fields": {
"title": "Output variable",
"attribute": "variable",
"identifier": "variable",
"order": 13
}
},
Expand All @@ -103,7 +103,7 @@
"pk": 24,
"fields": {
"title": "Temporal resolution",
"attribute": "time_step",
"identifier": "time_step",
"order": 11
}
},
Expand All @@ -112,7 +112,7 @@
"pk": 25,
"fields": {
"title": "Sector",
"attribute": "sector",
"identifier": "sector",
"order": 4
}
},
Expand All @@ -121,7 +121,7 @@
"pk": 26,
"fields": {
"title": "Impact model",
"attribute": "model",
"identifier": "model",
"order": 5
}
},
Expand All @@ -130,7 +130,7 @@
"pk": 27,
"fields": {
"title": "Simulation period",
"attribute": "period",
"identifier": "period",
"order": 3
}
},
Expand All @@ -139,7 +139,7 @@
"pk": 28,
"fields": {
"title": "Sensitivity scenario",
"attribute": "sens_scenario",
"identifier": "sens_scenario",
"order": 10
}
},
Expand All @@ -148,7 +148,7 @@
"pk": 29,
"fields": {
"title": "Spacial resolution",
"attribute": "resolution",
"identifier": "resolution",
"order": 12
}
}
Expand Down
4 changes: 3 additions & 1 deletion isimip_data/annotations/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ def test_query_datasets_before(db):


def test_format_affected_datasets(db):
affected_datasets = format_affected_datasets(Dataset.objects.filter(specifiers__contains={'model': 'model'}))
affected_datasets = format_affected_datasets(
Dataset.objects.using('metadata').filter(specifiers__contains={'model': 'model'})
)
assert len(re.findall(r'<br>', affected_datasets)) == 1
8 changes: 4 additions & 4 deletions testing/fixtures/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pk": 1,
"fields": {
"title": "Simulation round",
"attribute": "simulation_round",
"identifier": "simulation_round",
"order": 1
}
},
Expand All @@ -13,7 +13,7 @@
"pk": 2,
"fields": {
"title": "Product",
"attribute": "product",
"identifier": "product",
"order": 2
}
},
Expand All @@ -22,7 +22,7 @@
"pk": 3,
"fields": {
"title": "Sector",
"attribute": "sector",
"identifier": "sector",
"order": 3
}
},
Expand All @@ -31,7 +31,7 @@
"pk": 4,
"fields": {
"title": "Impact model",
"attribute": "model",
"identifier": "model",
"order": 4
}
}
Expand Down
12 changes: 6 additions & 6 deletions testing/sql/test_isimip_metadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ CREATE TABLE public.datasets (
ALTER TABLE public.datasets OWNER TO isimip_metadata;

--
-- Name: attributes; Type: MATERIALIZED VIEW; Schema: public; Owner: isimip_metadata
-- Name: identifiers; Type: MATERIALIZED VIEW; Schema: public; Owner: isimip_metadata
--

CREATE MATERIALIZED VIEW public.attributes AS
CREATE MATERIALIZED VIEW public.identifiers AS
SELECT specifiers.key AS identifier,
array_agg(DISTINCT specifiers.value) AS specifiers
FROM public.datasets,
Expand All @@ -74,7 +74,7 @@ CREATE MATERIALIZED VIEW public.attributes AS
WITH NO DATA;


ALTER TABLE public.attributes OWNER TO isimip_metadata;
ALTER TABLE public.identifiers OWNER TO isimip_metadata;

--
-- Name: files; Type: TABLE; Schema: public; Owner: isimip_metadata
Expand Down Expand Up @@ -261,7 +261,7 @@ ALTER TABLE ONLY public.trees
-- Name: attributes_identifier_idx; Type: INDEX; Schema: public; Owner: isimip_metadata
--

CREATE INDEX attributes_identifier_idx ON public.attributes USING btree (identifier);
CREATE INDEX identifiers_identifier_idx ON public.identifiers USING btree (identifier);


--
Expand Down Expand Up @@ -389,10 +389,10 @@ ALTER TABLE ONLY public.resources_datasets


--
-- Name: attributes; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: isimip_metadata
-- Name: identifiers; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: isimip_metadata
--

REFRESH MATERIALIZED VIEW public.attributes;
REFRESH MATERIALIZED VIEW public.identifiers;


--
Expand Down

0 comments on commit 985c8a9

Please # to comment.