def test_create_new_series(self): site = test_util.add_site(self.session) variable = test_util.add_variable(self.session) method = test_util.add_method(self.session) source = test_util.add_source(self.session) qcl = test_util.add_qcl(self.session) dvs = [] for val in range(10): dv = DataValue() dv.data_value = val dv.site_id = site.id dv.variable_id = variable.id dv.method_id = method.id dv.source_id = source.id dv.quality_control_level_id = qcl.id dvs.append(dv) series = self.series_service.create_new_series(dvs, site.id, variable.id, method.id, source.id, qcl.id) assert series != None assert len(series.data_values) == 10 assert series.site_id == site.id assert series.variable_id == variable.id
def test_get_all_sites(self): assert self.series_service.get_all_used_sites() == [] site = test_util.add_site(self.session) sites = self.series_service.get_all_used_sites() assert len(sites) == 0 if isinstance(sites, list) and len(sites) > 0: assert site.code == sites[0].code
def test_get_all_sites(self): assert self.series_service.get_used_sites() is None site = test_util.add_site(self.session) sites = self.series_service.get_used_sites() assert sites is None if isinstance(sites, list) and len(sites) > 0: assert site.code == sites[0].code series = test_util.add_series(self.session) site = series.site sites = self.series_service.get_used_sites() assert len(sites) == 1 if isinstance(sites, list) and len(sites) > 0: assert site.code == sites[0].code
def test_get_site_by_id(self): site = test_util.add_site(self.session) db_site = self.series_service.get_site_by_id(site.id) assert db_site != None assert site.code == db_site.code
def test_get_site_by_id_fail(self): assert self.series_service.get_site_by_id(0) == None site = test_util.add_site(self.session) db_site = self.series_service.get_site_by_id(10) assert db_site == None