diff --git a/toardb/contacts/fixtures/contacts.json b/toardb/contacts/fixtures/contacts.json new file mode 100644 index 0000000000000000000000000000000000000000..70f9156d4a7e51b52c00b3709623aa702a94fa64 --- /dev/null +++ b/toardb/contacts/fixtures/contacts.json @@ -0,0 +1,22 @@ +[ + { + "person_id": 1, + "organisation_id": 0 + }, + { + "person_id": 2, + "organisation_id": 0 + }, + { + "person_id": 3, + "organisation_id": 0 + }, + { + "person_id": 0, + "organisation_id": 1 + }, + { + "person_id": 0, + "organisation_id": 2 + } +] diff --git a/toardb/contacts/fixtures/organisations.json b/toardb/contacts/fixtures/organisations.json index eb7c07bfc0edd6416fdd564920577ecfee63fa01..a8185fc7bcf8c2a83ca95b9390ae76000d3b572e 100644 --- a/toardb/contacts/fixtures/organisations.json +++ b/toardb/contacts/fixtures/organisations.json @@ -1,4 +1,15 @@ [ + { + "id": 0, + "name": "", + "longname": "", + "kind": 7, + "city": "", + "postcode": "", + "street_address": "", + "country": "", + "homepage": "" + }, { "name": "UBA", "longname": "Umweltbundesamt", diff --git a/toardb/contacts/fixtures/persons.json b/toardb/contacts/fixtures/persons.json index d44b39a1efdc781e365cbc1c389a66929de86ccc..15622d7561ba5f4d9ac2cbf899b56d5a84b45edb 100644 --- a/toardb/contacts/fixtures/persons.json +++ b/toardb/contacts/fixtures/persons.json @@ -1,4 +1,9 @@ [ + { + "id": 0, + "name": "", + "email": "" + }, { "name": "Stefan Feigenspan", "email": "Stefan.Feigenspan@uba.de", diff --git a/toardb/contacts/models.py b/toardb/contacts/models.py index 3846012f8d85f4351daadb49e598b74c946f0ce8..a3babb0972f40a94f2667c9c8ecd23e2db4421b5 100644 --- a/toardb/contacts/models.py +++ b/toardb/contacts/models.py @@ -68,7 +68,7 @@ class Contact(Base): UniqueConstraint('person_id', 'organisation_id') ) - id = Column(Integer, primary_key=True, server_default=text("nextval('contacts_id_seq'::regclass)")) + id = Column(Integer, CONTACTS_ID_SEQ, primary_key=True, server_default=CONTACTS_ID_SEQ.next_value()) person_id = Column(ForeignKey('persons.id')) organisation_id = Column(ForeignKey('organisations.id')) diff --git a/toardb/contacts/models_person.py b/toardb/contacts/models_person.py index 9d3c27adb95370d91c272911b438ea2c394968a5..19c9c44259d6878254d44b0709a2efdc6fd372b2 100644 --- a/toardb/contacts/models_person.py +++ b/toardb/contacts/models_person.py @@ -3,7 +3,7 @@ class Person (Base) =================== """ -from sqlalchemy import Boolean, Column, Integer, String, Sequence, UniqueConstraint +from sqlalchemy import Boolean, Column, Integer, String, Sequence, UniqueConstraint, text from toardb.base import Base PERSONS_ID_SEQ = Sequence('persons_id_seq') # define sequence explicitly @@ -19,9 +19,9 @@ class Person(Base): +-----------+------------------------+-----------+----------+-------------------------------------+ | email | character varying(128) | | not null | | +-----------+------------------------+-----------+----------+-------------------------------------+ - | phone | character varying(32) | | not null | | + | phone | character varying(32) | | not null | ''::character varying | +-----------+------------------------+-----------+----------+-------------------------------------+ - | isprivate | boolean | | not null | | + | isprivate | boolean | | not null | true | +-----------+------------------------+-----------+----------+-------------------------------------+ Indexes: "persons_pkey" PRIMARY KEY, btree (id) @@ -39,6 +39,6 @@ class Person(Base): id = Column(Integer, PERSONS_ID_SEQ, primary_key=True, server_default=PERSONS_ID_SEQ.next_value()) name = Column(String(64), nullable=False) email = Column(String(128), nullable=False) - phone = Column(String(32), nullable=False) - isprivate = Column(Boolean, nullable=False) + phone = Column(String(32), nullable=False, server_default=text("''::character varying")) + isprivate = Column(Boolean, nullable=False, server_default=text("true")) diff --git a/toardb/contacts/test_contacts.py b/toardb/contacts/test_contacts.py index 7eabaed6856792a2bc7466f8e486e2b4ea7d85f6..c1aacb5eb9e48d16dfad227564a3d98d62ef1977 100644 --- a/toardb/contacts/test_contacts.py +++ b/toardb/contacts/test_contacts.py @@ -1,6 +1,6 @@ import pytest import json -from .models import Person, Organisation +from .models import Person, Organisation, Contact # Required imports 'create_test_database' from toardb.test_base import ( client, @@ -30,6 +30,8 @@ class TestApps: fake_conn.commit() fake_cur.execute("ALTER SEQUENCE organisations_id_seq RESTART WITH 1") fake_conn.commit() + fake_cur.execute("ALTER SEQUENCE contacts_id_seq RESTART WITH 1") + fake_conn.commit() infilename = "toardb/contacts/fixtures/persons.json" with open(infilename) as f: metajson=json.load(f) @@ -46,13 +48,25 @@ class TestApps: db.add(new_organisation) db.commit() db.refresh(new_organisation) + infilename = "toardb/contacts/fixtures/contacts.json" + with open(infilename) as f: + metajson=json.load(f) + for entry in metajson: + new_contact = Contact(**entry) + db.add(new_contact) + db.commit() + db.refresh(new_contact) def test_get_organisations(self, client, db): response = client.get("/contacts/organisations/") expected_status_code = 200 assert response.status_code == expected_status_code - expected_resp = [{"id":1,"name":"UBA","longname":"Umweltbundesamt", + expected_resp = [{"id":0,"name":"","longname":"", + "kind":"Other","city":"","postcode":"", + "street_address":"","country":"", + "homepage":""}, + {"id":1,"name":"UBA","longname":"Umweltbundesamt", "kind":"Government","city":"Dessau-Roßlau","postcode":"06844", "street_address":"Wörlitzer Platz 1","country":"Germany", "homepage":"https://www.umweltbundesamt.de"}, @@ -149,8 +163,9 @@ class TestApps: response = client.get("/contacts/persons/") expected_status_code = 200 assert response.status_code == expected_status_code - print("I got: ", response.json()) - expected_resp = [{'id': 1, 'name': 'Stefan Feigenspan', 'email': 'Stefan.Feigenspan@uba.de', + expected_resp = [{'id': 0, 'name': '', 'email': '', + 'phone': '', 'isprivate': True}, + {'id': 1, 'name': 'Stefan Feigenspan', 'email': 'Stefan.Feigenspan@uba.de', 'phone': '+49 / (0)340 / 2103-2089', 'isprivate': True}, {'id': 2, 'name': 'Ute Dauert', 'email': 'Ute.Dauert@uba.de', 'phone': '+49-340-2103-2531', 'isprivate': True}, @@ -227,3 +242,31 @@ class TestApps: assert response.status_code == expected_status_code expected_resp = {'detail': 'Person already registered.'} assert response.json() == expected_resp + + +## also test requiring all contacts (a contact is either an organisation or a person) + def test_get_contacts(self, client, db): + response = client.get("/contacts/") + expected_status_code = 200 + assert response.status_code == expected_status_code + expected_resp = [{'person': {'id': 1, 'name': 'Stefan Feigenspan', 'email': 'Stefan.Feigenspan@uba.de', + 'phone': '+49 / (0)340 / 2103-2089', 'isprivate': True}, + 'organisation': {'id': 0, 'name': '', 'longname': '', 'kind': 'Other', 'city': '', + 'postcode': '', 'street_address': '', 'country': '', 'homepage': ''}}, + {'person': {'id': 2, 'name': 'Ute Dauert', 'email': 'Ute.Dauert@uba.de', + 'phone': '+49-340-2103-2531', 'isprivate': True}, + 'organisation': {'id': 0, 'name': '', 'longname': '', 'kind': 'Other', 'city': '', + 'postcode': '', 'street_address': '', 'country': '', 'homepage': ''}}, + {'person': {'id': 3, 'name': 'Sabine Schröder', 'email': 's.schroeder@fz-juelich.de', + 'phone': '+49-2461-61-6397', 'isprivate': True}, + 'organisation': {'id': 0, 'name': '', 'longname': '', 'kind': 'Other', 'city': '', + 'postcode': '', 'street_address': '', 'country': '', 'homepage': ''}}, + {'person': {'id': 0, 'name': '', 'email': '', 'phone': '', 'isprivate': True}, + 'organisation': {'id': 1, 'name': 'UBA', 'longname': 'Umweltbundesamt', 'kind': 'Government', + 'city': 'Dessau-Roßlau', 'postcode': '06844', 'street_address': 'Wörlitzer Platz 1', + 'country': 'Germany', 'homepage': 'https://www.umweltbundesamt.de'}}, + {'person': {'id': 0, 'name': '', 'email': '', 'phone': '', 'isprivate': True}, + 'organisation': {'id': 2, 'name': 'FZJ', 'longname': 'Forschungszentrum Jülich', 'kind': 'Research', + 'city': 'Jülich', 'postcode': '52425', 'street_address': 'Wilhelm-Johnen-Straße', + 'country': 'Germany', 'homepage': 'https://www.fz-juelich.de'}}] + assert response.json() == expected_resp diff --git a/toardb/data/test_data.py b/toardb/data/test_data.py index 5e90381af3691a4759cf4897c7a343a227ce7e6d..1a9a25b488d9254d4d38208ba5cee318eae7769f 100644 --- a/toardb/data/test_data.py +++ b/toardb/data/test_data.py @@ -2,10 +2,11 @@ import pytest import json from .models import Data from toardb.timeseries.models import Timeseries +from toardb.timeseries.models_programme import TimeseriesProgramme from toardb.stationmeta.models import StationmetaCore from toardb.stationmeta.schemas import get_geom_from_coordinates, Coordinates from toardb.variables.models import Variable -from toardb.contacts.models import Person, Organisation +from toardb.contacts.models import Person, Organisation, Contact from toardb.auth_user.models import AuthUser from toardb.test_base import ( client, @@ -55,10 +56,14 @@ class TestApps: fake_conn.commit() fake_cur.execute("ALTER SEQUENCE organisations_id_seq RESTART WITH 1") fake_conn.commit() + fake_cur.execute("ALTER SEQUENCE contacts_id_seq RESTART WITH 1") + fake_conn.commit() fake_cur.execute("ALTER SEQUENCE timeseries_annotations_id_seq RESTART WITH 1") fake_conn.commit() fake_cur.execute("ALTER SEQUENCE timeseries_roles_id_seq RESTART WITH 1") fake_conn.commit() + fake_cur.execute("ALTER SEQUENCE timeseries_programmes_id_seq RESTART WITH 1") + fake_conn.commit() fake_cur.execute("ALTER SEQUENCE timeseries_id_seq RESTART WITH 1") fake_conn.commit() infilename = "toardb/auth_user/fixtures/auth.json" @@ -85,6 +90,14 @@ class TestApps: db.add(new_organisation) db.commit() db.refresh(new_organisation) + infilename = "toardb/contacts/fixtures/contacts.json" + with open(infilename) as f: + metajson=json.load(f) + for entry in metajson: + new_contact = Contact(**entry) + db.add(new_contact) + db.commit() + db.refresh(new_contact) infilename = "toardb/variables/fixtures/variables.json" with open(infilename) as f: metajson=json.load(f) @@ -108,6 +121,14 @@ class TestApps: db.add(new_stationmeta_core) db.commit() db.refresh(new_stationmeta_core) + infilename = "toardb/timeseries/fixtures/timeseries_programmes.json" + with open(infilename) as f: + metajson=json.load(f) + for entry in metajson: + new_timeseries_programme = TimeseriesProgramme(**entry) + db.add(new_timeseries_programme) + db.commit() + db.refresh(new_timeseries_programme) infilename = "toardb/timeseries/fixtures/timeseries.json" with open(infilename) as f: metajson=json.load(f) @@ -135,7 +156,7 @@ class TestApps: {'datetime': '2012-12-16T23:00:00+01:00', 'value': 13.734, 'flags': 'OK', 'timeseries_id': 1}, {'datetime': '2012-12-17T00:00:00+01:00', 'value': 7.848, 'flags': 'OK', 'timeseries_id': 1}] assert response.json() == expected_resp - + def test_get_special(self, client, db): response = client.get("/data/1") @@ -152,7 +173,7 @@ class TestApps: {'datetime': '2012-12-17T05:00:00+01:00', 'value': 15.696, 'flags': 'OK', 'timeseries_id': 1}, {'datetime': '2012-12-17T06:00:00+01:00', 'value': 5.886, 'flags': 'OK', 'timeseries_id': 1}] assert response.json() == expected_resp - + # def test_insert_new_without_credits(self): #? response = client.post("/data/") @@ -177,7 +198,7 @@ class TestApps: assert response.status_code == expected_status_code expected_resp = 'Data successfully inserted.' assert response.json() == expected_resp - + def test_insert_duplicate(self, client, db): response = client.post("/data/", files={"file": open("toardb/data/fixtures/toluene_SDZ54421_2012_2012_v1-0.dat", "rb")}) @@ -185,7 +206,7 @@ class TestApps: assert response.status_code == expected_status_code expected_resp = {'detail': 'Data for timeseries already registered.'} assert response.json() == expected_resp - + def test_insert_missing_id(self, client, db): response = client.post("/data/", files={"file": open("toardb/data/fixtures/o3_SDZ54421_2012_2012_v1-0.dat", "rb")}) diff --git a/toardb/timeseries/fixtures/timeseries_programmes.json b/toardb/timeseries/fixtures/timeseries_programmes.json new file mode 100644 index 0000000000000000000000000000000000000000..3d55df333038c24227957883e428cddf2439afcd --- /dev/null +++ b/toardb/timeseries/fixtures/timeseries_programmes.json @@ -0,0 +1,27 @@ +[ + { + "id": 0, + "name": "", + "longname": "", + "homepage": "", + "description": "" + }, + { + "name": "EMEP", + "longname": "Co-operative programme for monitoring and evaluation of the long-range transmission of air pollutants in Europe", + "homepage": "https://www.emep.int/", + "description": "EMEP is a scientifically based and policy driven programme under the Convention on Long-range Transboundary Air Pollution (CLRTAP) for international co-operation to solve transboundary air pollution problems." + }, + { + "name": "GAW", + "longname": "Global Atmosphere Watch Programme of WMO", + "homepage": "https://community.wmo.int/activity-areas/gaw", + "description": "GAW focuses on building a single coordinated global understanding of atmospheric composition, its change, and helps to improve the understanding of interactions between the atmosphere, the oceans and the biosphere." + }, + { + "name": "OpenAQ", + "longname": "OpenAQ", + "homepage": "https://openaq.org", + "description": "OpenAQ is a non-profit organization empowering communities around the globe to clean their air by harmonizing, sharing, and using open air quality data." + } +] diff --git a/toardb/timeseries/test_timeseries.py b/toardb/timeseries/test_timeseries.py index 39a10d7d7748390f4b3d6413f45b880946f779d5..0fad17edc96ba71b20028f2613072a28ae3ef014 100644 --- a/toardb/timeseries/test_timeseries.py +++ b/toardb/timeseries/test_timeseries.py @@ -1,10 +1,11 @@ import pytest import json from .models import Timeseries +from .models_programme import TimeseriesProgramme from toardb.stationmeta.models import StationmetaCore from toardb.stationmeta.schemas import get_geom_from_coordinates, Coordinates from toardb.variables.models import Variable -from toardb.contacts.models import Person, Organisation +from toardb.contacts.models import Person, Organisation, Contact from toardb.auth_user.models import AuthUser # Required imports 'create_test_database' from toardb.test_base import ( @@ -55,10 +56,14 @@ class TestApps: fake_conn.commit() fake_cur.execute("ALTER SEQUENCE organisations_id_seq RESTART WITH 1") fake_conn.commit() + fake_cur.execute("ALTER SEQUENCE contacts_id_seq RESTART WITH 1") + fake_conn.commit() fake_cur.execute("ALTER SEQUENCE timeseries_annotations_id_seq RESTART WITH 1") fake_conn.commit() fake_cur.execute("ALTER SEQUENCE timeseries_roles_id_seq RESTART WITH 1") fake_conn.commit() + fake_cur.execute("ALTER SEQUENCE timeseries_programmes_id_seq RESTART WITH 1") + fake_conn.commit() fake_cur.execute("ALTER SEQUENCE timeseries_id_seq RESTART WITH 1") fake_conn.commit() infilename = "toardb/auth_user/fixtures/auth.json" @@ -85,6 +90,14 @@ class TestApps: db.add(new_organisation) db.commit() db.refresh(new_organisation) + infilename = "toardb/contacts/fixtures/contacts.json" + with open(infilename) as f: + metajson=json.load(f) + for entry in metajson: + new_contact = Contact(**entry) + db.add(new_contact) + db.commit() + db.refresh(new_contact) infilename = "toardb/variables/fixtures/variables.json" with open(infilename) as f: metajson=json.load(f) @@ -109,6 +122,14 @@ class TestApps: db.add(new_stationmeta_core) db.commit() db.refresh(new_stationmeta_core) + infilename = "toardb/timeseries/fixtures/timeseries_programmes.json" + with open(infilename) as f: + metajson=json.load(f) + for entry in metajson: + new_timeseries_programme = TimeseriesProgramme(**entry) + db.add(new_timeseries_programme) + db.commit() + db.refresh(new_timeseries_programme) infilename = "toardb/timeseries/fixtures/timeseries.json" with open(infilename) as f: metajson=json.load(f) @@ -126,10 +147,17 @@ class TestApps: expected_resp = [{'id': 1, 'label': 'CMA', 'order': 1, 'access_rights': 'ByAttribution', 'sampling_frequency': 'Hourly', 'aggregation': 'Mean', 'source': 'Measurement', 'data_start_date': '2003-09-07T15:30:00+02:00', 'data_end_date': '2016-12-31T14:30:00+01:00', - 'measurement_method': 'UV absorption', 'sampling_height': 7.0, + 'measurement_method': 'UVAbsorption', 'sampling_height': 7.0, 'date_added': '2020-05-15T15:30:00+02:00', 'date_modified': '2020-05-16T09:30:00+02:00', - 'station_id': 2, 'variable_id': 7, - 'additional_metadata':{}, 'roles': [], 'annotations': [], 'programmes': []}] + 'additional_metadata': {}, 'roles': [], 'annotations': [], + 'variable': {'name': 'toluene', 'longname': 'toluene', 'displayname': 'Toluene', + 'cf_standardname': 'mole_fraction_of_toluene_in_air', 'units': 'nmol mol-1', + 'chemical_formula': 'C7H8', 'id': 7}, + 'station': {'additional_metadata': '{}', 'type_of_area': 0, + 'coordinate_validation_date': '2020-02-28T12:27:03.746260+01:00', 'country': 'China', + 'codes': ['SDZ54421'], 'coordinate_validation_status': 0, 'coordinate_validator_id': 1, + 'timezone': '', 'type_of_environment': 0, 'state': 'Beijing Shi', 'name': 'Shangdianzi', 'id': 2}, + 'programme': {'id': 0, 'name': '', 'longname': '', 'homepage': '', 'description': ''}}] assert response.json() == expected_resp @@ -148,10 +176,17 @@ class TestApps: expected_resp = {'id': 1, 'label': 'CMA', 'order': 1, 'access_rights': 'ByAttribution', 'sampling_frequency': 'Hourly', 'aggregation': 'Mean', 'source': 'Measurement', 'data_start_date': '2003-09-07T15:30:00+02:00', 'data_end_date': '2016-12-31T14:30:00+01:00', - 'measurement_method': 'UV absorption', 'sampling_height': 7.0, + 'measurement_method': 'UVAbsorption', 'sampling_height': 7.0, 'date_added': '2020-05-15T15:30:00+02:00', 'date_modified': '2020-05-16T09:30:00+02:00', - 'station_id': 2, 'variable_id': 7, - 'additional_metadata':{}, 'roles': [], 'annotations': [], 'programmes': []} + 'additional_metadata': {}, 'roles': [], 'annotations': [], + 'variable': {'name': 'toluene', 'longname': 'toluene', 'displayname': 'Toluene', + 'cf_standardname': 'mole_fraction_of_toluene_in_air', 'units': 'nmol mol-1', + 'chemical_formula': 'C7H8', 'id': 7}, + 'station': {'additional_metadata': '{}', 'type_of_area': 0, + 'coordinate_validation_date': '2020-02-28T12:27:03.746260+01:00', 'country': 'China', + 'codes': ['SDZ54421'], 'coordinate_validation_status': 0, 'coordinate_validator_id': 1, + 'timezone': '', 'type_of_environment': 0, 'state': 'Beijing Shi', 'name': 'Shangdianzi', 'id': 2}, + 'programme': {'id': 0, 'name': '', 'longname': '', 'homepage': '', 'description': ''}} assert response.json() == expected_resp @@ -179,7 +214,7 @@ class TestApps: "sampling_frequency": "Hourly", "aggregation": "Mean", "source": "Measurement", "data_start_date": "2003-09-07T15:30:00+02:00", "data_end_date": "2016-12-31T14:30:00+01:00", - "measurement_method": "UV absorption", "sampling_height": 7.0, + "measurement_method": "UVAbsorption", "sampling_height": 7.0, "date_added": "2020-05-15T15:30:00+02:00", "date_modified": "2020-05-16T09:30:00+02:00", "station_id": 2, "variable_id": 7, "additional_metadata":"{}"} @@ -190,10 +225,20 @@ class TestApps: expected_resp = {'id': 2, 'label': 'CMA2', 'order': 1, 'access_rights': 'ByAttribution', 'sampling_frequency': 'Hourly', 'aggregation': 'Mean', 'source': 'Measurement', 'data_start_date': '2003-09-07T15:30:00+02:00', 'data_end_date': '2016-12-31T14:30:00+01:00', - 'measurement_method': 'UV absorption', 'sampling_height': 7.0, + 'measurement_method': 'UVAbsorption', 'sampling_height': 7.0, 'date_added': '2020-05-15T15:30:00+02:00', 'date_modified': '2020-05-16T09:30:00+02:00', - 'station_id': 2, 'variable_id': 7, - 'additional_metadata':{}, 'roles': [], 'annotations': [], 'programmes': []} + 'additional_metadata': {}, + 'roles': [], + 'annotations': [], + 'variable': {'name': 'toluene', 'longname': 'toluene', 'displayname': 'Toluene', + 'cf_standardname': 'mole_fraction_of_toluene_in_air', 'units': 'nmol mol-1', + 'chemical_formula': 'C7H8', 'id': 7}, + 'station': {'additional_metadata': '{}', 'type_of_area': 0, + 'coordinate_validation_date': '2020-02-28T12:27:03.746260+01:00', + 'country': 'China', 'codes': ['SDZ54421'], 'coordinate_validation_status': 0, + 'coordinate_validator_id': 1, 'timezone': '', 'type_of_environment': 0, + 'state': 'Beijing Shi', 'name': 'Shangdianzi', 'id': 2}, + 'programme': {'id': 0, 'name': '', 'longname': '', 'homepage': '', 'description': ''}} assert response.json() == expected_resp @@ -204,12 +249,12 @@ class TestApps: "sampling_frequency": "Hourly", "aggregation": "Mean", "source": "Measurement", "data_start_date": "2003-09-07T15:30:00+02:00", "data_end_date": "2016-12-31T14:30:00+01:00", - "measurement_method": "UV absorption", "sampling_height": 7.0, + "measurement_method": "UVAbsorption", "sampling_height": 7.0, "date_added": "2020-05-15T15:30:00+02:00", "date_modified": "2020-05-16T09:30:00+02:00", "station_id": 2, "variable_id": 7, "additional_metadata":"{}", - "roles": [{"role": "PointOfContact", "person_id": 3, "status": "active"}, - {"role": "Originator", "person_id": 1, "status": "active"}] + "roles": [{"role": "PointOfContact", "contact_id": 3, "status": "active"}, + {"role": "Originator", "contact_id": 1, "status": "active"}] } } ) @@ -218,12 +263,21 @@ class TestApps: expected_resp = {'id': 2, 'label': 'CMA2', 'order': 1, 'access_rights': 'ByAttribution', 'sampling_frequency': 'Hourly', 'aggregation': 'Mean', 'source': 'Measurement', 'data_start_date': '2003-09-07T15:30:00+02:00', 'data_end_date': '2016-12-31T14:30:00+01:00', - 'measurement_method': 'UV absorption', 'sampling_height': 7.0, + 'measurement_method': 'UVAbsorption', 'sampling_height': 7.0, 'date_added': '2020-05-15T15:30:00+02:00', 'date_modified': '2020-05-16T09:30:00+02:00', - 'station_id': 2, 'variable_id': 7, - 'additional_metadata':{}, - 'roles': [{'id': 1, 'person_id': 3, 'role': 'PointOfContact', 'status': 'active'}, {'id': 2, 'person_id': 1, 'role': 'Originator', 'status': 'active'}], - 'annotations': [], 'programmes': []} + 'additional_metadata': {}, + 'roles': [{'id': 1, 'role': 'PointOfContact', 'status': 'active', 'contact_id': 3}, + {'id': 2, 'role': 'Originator', 'status': 'active', 'contact_id': 1}], + 'annotations': [], + 'variable': {'name': 'toluene', 'longname': 'toluene', 'displayname': 'Toluene', + 'cf_standardname': 'mole_fraction_of_toluene_in_air', 'units': 'nmol mol-1', + 'chemical_formula': 'C7H8', 'id': 7}, + 'station': {'additional_metadata': '{}', 'type_of_area': 0, + 'coordinate_validation_date': '2020-02-28T12:27:03.746260+01:00', + 'country': 'China', 'codes': ['SDZ54421'], 'coordinate_validation_status': 0, + 'coordinate_validator_id': 1, 'timezone': '', 'type_of_environment': 0, + 'state': 'Beijing Shi', 'name': 'Shangdianzi', 'id': 2}, + 'programme': {'id': 0, 'name': '', 'longname': '', 'homepage': '', 'description': ''}} assert response.json() == expected_resp @@ -234,12 +288,12 @@ class TestApps: "sampling_frequency": "Hourly", "aggregation": "Mean", "source": "Measurement", "data_start_date": "2003-09-07T15:30:00+02:00", "data_end_date": "2016-12-31T14:30:00+01:00", - "measurement_method": "UV absorption", "sampling_height": 7.0, + "measurement_method": "UVAbsorption", "sampling_height": 7.0, "date_added": "2020-05-15T15:30:00+02:00", "date_modified": "2020-05-16T09:30:00+02:00", "station_id": 2, "variable_id": 7, "additional_metadata":"{}", - "roles": [{"role": "PointOfContact", "person_id": 3, "status": "active"}, - {"role": "Originator", "person_id": 1, "status": "active"}] + "roles": [{"role": "PointOfContact", "contact_id": 3, "status": "active"}, + {"role": "Originator", "contact_id": 1, "status": "active"}] } } )