Exemplo n.º 1
0
    def test_get_series_by_id(self):
        assert self.series_service.get_series_by_id(10) == None

        series = test_util.add_series(self.session)
        db_series = self.series_service.get_series_by_id(series.id)

        assert series.id == db_series.id
Exemplo n.º 2
0
	def test_get_series_by_id(self):
		assert self.series_service.get_series_by_id(10) == None

		series = test_util.add_series(self.session)
		db_series = self.series_service.get_series_by_id(series.id)

		assert series.id == db_series.id
Exemplo n.º 3
0
	def setup(self):
		self.connection_string = "sqlite:///:memory:"
		session_factory = SessionFactory(self.connection_string, echo=False)
		test_util.build_db(session_factory.engine)
		self.session = session_factory.get_session()
		self.series = test_util.add_series(self.session)
		self.data_values = self.series.data_values
Exemplo n.º 4
0
 def setup(self):
     self.connection_string = "sqlite:///:memory:"
     session_factory = SessionFactory(self.connection_string, echo=False)
     test_util.build_db(session_factory.engine)
     self.session = session_factory.get_session()
     self.series = test_util.add_series(self.session)
     self.data_values = self.series.data_values
Exemplo n.º 5
0
	def test_get_data_value_by_id(self):
		assert self.series_service.get_data_value_by_id(10) == None

		data_values = test_util.add_series(self.session).data_values
		dv = data_values[0]
		db_dv = self.series_service.get_data_value_by_id(dv.id)

		assert dv.data_value == db_dv.data_value
Exemplo n.º 6
0
    def test_get_all_series(self):
        assert self.series_service.get_all_series() == []

        series = test_util.add_series(self.session)
        all_series = self.series_service.get_all_series()

        assert all_series != []
        assert series.id == all_series[0].id
Exemplo n.º 7
0
	def test_get_all_series(self):
		assert self.series_service.get_all_series() == []

		series = test_util.add_series(self.session)
		all_series = self.series_service.get_all_series()

		assert all_series != []
		assert series.id == all_series[0].id
Exemplo n.º 8
0
    def test_get_data_value_by_id(self):
        assert self.series_service.get_data_value_by_id(10) == None

        data_values = test_util.add_series(self.session).data_values
        dv = data_values[0]
        db_dv = self.series_service.get_data_value_by_id(dv.id)

        assert dv.data_value == db_dv.data_value
Exemplo n.º 9
0
    def test_delete_dvs(self):
        series = test_util.add_series(self.session)
        dvs = series.data_values

        subset = dvs[:5]
        self.series_service.delete_dvs(subset)
        assert self.series_service.get_data_value_by_id(subset[0].id) == None
        series = self.series_service.get_series_by_id(series.id)  # Reload
        assert len(series.data_values) == 5
Exemplo n.º 10
0
	def test_get_series_by_id_quint(self):
		assert self.series_service.get_series_by_id_quint(10, 10, 10, 10, 10) == None

		series = test_util.add_series(self.session)
		db_series = self.series_service.get_series_by_id_quint(
			series.site_id, series.variable_id, series.method_id,
			series.source_id, series.quality_control_level_id)

		assert series.id == db_series.id
Exemplo n.º 11
0
	def setup(self):		
		self.connection_string = "sqlite:///:memory:"
		self.series_service = SeriesService(self.connection_string, debug=False)
		self.session = self.series_service._session_factory.getSession()
		engine = self.series_service._session_factory.engine
		test_util.build_db(engine)
		self.series = test_util.add_series(self.session)

		self.export_service = ExportService(self.series_service)
Exemplo n.º 12
0
	def test_get_variables_by_site_code(self):
		assert self.series_service.get_variables_by_site_code('ABC123') == []

		series = test_util.add_series(self.session)
		variable = series.variable

		db_variables = self.series_service.get_variables_by_site_code(series.site_code)
		assert db_variables != None
		assert variable.code == db_variables[0].code
Exemplo n.º 13
0
	def test_delete_dvs(self):
		series = test_util.add_series(self.session)
		dvs = series.data_values

		subset = dvs[:5]
		self.series_service.delete_dvs(subset)
		assert self.series_service.get_data_value_by_id(subset[0].id) == None
		series = self.series_service.get_series_by_id(series.id)  # Reload
		assert len(series.data_values) == 5
Exemplo n.º 14
0
	def setup(self):
		self.connection_string = "sqlite:///:memory:"
		self.series_service = SeriesService(connection_string=self.connection_string, debug=False)
		self.session = self.series_service._session_factory.get_session()
		engine = self.series_service._session_factory.engine
		test_util.build_db(engine)
		self.series = test_util.add_series(self.session)

		self.memory_db = MemoryDatabase(self.series_service)
Exemplo n.º 15
0
	def test_update_series(self):
		series = test_util.add_series(self.session)
		series.site_code = "NEW"
		series.variable_code = "NEW"

		self.series_service.update_series(series)

		series = self.series_service.get_series_by_id(series.id)
		assert series.site_code == "NEW"
		assert series.variable_code == "NEW"
Exemplo n.º 16
0
    def test_get_series_by_id_quint(self):
        assert self.series_service.get_series_by_id_quint(10, 10, 10, 10,
                                                          10) == None

        series = test_util.add_series(self.session)
        db_series = self.series_service.get_series_by_id_quint(
            series.site_id, series.variable_id, series.method_id,
            series.source_id, series.quality_control_level_id)

        assert series.id == db_series.id
Exemplo n.º 17
0
    def test_get_variables_by_site_code(self):
        assert self.series_service.get_variables_by_site_code('ABC123') == []

        series = test_util.add_series(self.session)
        variable = series.variable

        db_variables = self.series_service.get_variables_by_site_code(
            series.site_code)
        assert db_variables != None
        assert variable.code == db_variables[0].code
Exemplo n.º 18
0
    def test_update_series(self):
        series = test_util.add_series(self.session)
        series.site_code = "NEW"
        series.variable_code = "NEW"

        self.series_service.update_series(series)

        series = self.series_service.get_series_by_id(series.id)
        assert series.site_code == "NEW"
        assert series.variable_code == "NEW"
Exemplo n.º 19
0
	def test_series_exists(self):
		assert self.series_service.series_exists(10,10,10,10,10) == False

		series = test_util.add_series(self.session)
		site_id = series.site_id
		var_id = series.variable_id
		method_id = series.method_id
		source_id = series.source_id
		qcl_id = series.quality_control_level_id

		assert self.series_service.series_exists(site_id,var_id,method_id,source_id,qcl_id) == True
Exemplo n.º 20
0
	def test_update_dvs(self):
		series = test_util.add_series(self.session)
		dvs = series.data_values

		subset = dvs[:5]
		for i in range(len(subset)):
			subset[i].data_value = 100

		self.series_service.update_dvs(subset)
		series = self.series_service.get_series_by_id(series.id)
		assert series.data_values[0].data_value == 100
Exemplo n.º 21
0
    def test_update_dvs(self):
        series = test_util.add_series(self.session)
        dvs = series.data_values

        subset = dvs[:5]
        for i in range(len(subset)):
            subset[i].data_value = 100

        self.series_service.update_dvs(subset)
        series = self.series_service.get_series_by_id(series.id)
        assert series.data_values[0].data_value == 100
Exemplo n.º 22
0
    def test_series_exists(self):
        assert self.series_service.series_exists(10, 10, 10, 10, 10) == False

        series = test_util.add_series(self.session)
        site_id = series.site_id
        var_id = series.variable_id
        method_id = series.method_id
        source_id = series.source_id
        qcl_id = series.quality_control_level_id

        assert self.series_service.series_exists(site_id, var_id, method_id,
                                                 source_id, qcl_id) == True
Exemplo n.º 23
0
	def test_delete_series(self):
		series = test_util.add_series(self.session)		
		assert self.series_service.get_series_by_id(series.id) != None

		self.series_service.delete_series(series)
		assert self.series_service.get_series_by_id(series.id) == None
Exemplo n.º 24
0
    def test_delete_series(self):
        series = test_util.add_series(self.session)
        assert self.series_service.get_series_by_id(series.id) != None

        self.series_service.delete_series(series)
        assert self.series_service.get_series_by_id(series.id) == None