Ejemplo n.º 1
0
    def test_store_other(self):

        # Test text output
        text_output = ComplexOutput('txt',
                                    'Plain text output',
                                    supported_formats=[FORMATS.TEXT])
        text_output.file = get_text_file()
        text_output.output_format = FORMATS.TEXT

        store_text = self.storage.store(text_output)

        assert len(store_text) == 3
        assert store_text[0] == STORE_TYPE.DB
        assert isinstance(store_text[1], str)
        assert isinstance(store_text[2], str)

        # Parse reference into path to db and table
        reference = store_text[2].rsplit(".", 1)

        db_url = "sqlite:///{}".format(reference[0])
        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)
        assert (reference[1] in ins.get_table_names())

        # Test CSV output
        csv_output = ComplexOutput('csv',
                                   'CSV output',
                                   supported_formats=[FORMATS.CSV])
        csv_output.file = get_csv_file()
        csv_output.output_format = FORMATS.CSV

        store_csv = self.storage.store(csv_output)

        assert len(store_csv) == 3
        assert store_csv[0] == STORE_TYPE.DB
        assert isinstance(store_csv[1], str)
        assert isinstance(store_csv[2], str)

        # Parse reference into path to db and table
        reference = store_csv[2].rsplit(".", 1)

        db_url = "sqlite:///{}".format(reference[0])

        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)
        assert (reference[1] in ins.get_table_names())
Ejemplo n.º 2
0
    def test_store_other(self):
        text_output = ComplexOutput('txt',
                                    'Plain text output',
                                    supported_formats=[FORMATS.TEXT])
        text_output.file = get_text_file()
        text_output.output_format = FORMATS.TEXT

        store_text = self.storage.store(text_output)

        assert len(store_text) == 3
        assert store_text[0] == STORE_TYPE.DB
        assert isinstance(store_text[1], str)
        assert isinstance(store_text[2], str)

        # Parse reference into dbname, schema and table
        reference = store_text[2].split(".")

        db_url = "postgresql://{}:{}@{}:{}/{}".format(reference[0],
                                                      self.password, self.host,
                                                      self.port, self.user)
        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)
        assert (reference[2] in ins.get_table_names(schema=reference[1]))

        csv_output = ComplexOutput('csv',
                                   'CSV output',
                                   supported_formats=[FORMATS.CSV])
        csv_output.file = get_csv_file()
        csv_output.output_format = FORMATS.CSV

        store_csv = self.storage.store(csv_output)

        assert len(store_csv) == 3
        assert store_csv[0] == STORE_TYPE.DB
        assert isinstance(store_csv[1], str)
        assert isinstance(store_csv[2], str)

        # Parse reference into dbname, schema and table
        reference = store_csv[2].split(".")

        db_url = "postgresql://{}:{}@{}:{}/{}".format(reference[0],
                                                      self.password, self.host,
                                                      self.port, self.user)
        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)
        assert (reference[2] in ins.get_table_names(schema=reference[1]))
Ejemplo n.º 3
0
    def test_store(self):
        vector_output = ComplexOutput('vector',
                                      'Vector output',
                                      supported_formats=[FORMATS.GML])
        vector_output.file = get_vector_file()

        store_file = self.storage.store(vector_output)
        assert len(store_file) == 3
        assert store_file[0] == STORE_TYPE.PATH
        assert isinstance(store_file[1], str)
        assert isinstance(store_file[2], str)
Ejemplo n.º 4
0
    def test_store_vector(self):
        vector_output = ComplexOutput('vector',
                                      'Vector output',
                                      supported_formats=[FORMATS.GML])
        vector_output.file = get_vector_file()
        vector_output.output_format = FORMATS.GML
        store_vector = self.storage.store(vector_output)

        assert len(store_vector) == 3
        assert store_vector[0] == STORE_TYPE.DB
        assert isinstance(store_vector[1], str)
        assert isinstance(store_vector[2], str)

        # Parse reference into path to db and table
        reference = store_vector[2].rsplit(".", 1)

        db_url = "sqlite:///{}".format(reference[0])
        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)
        assert (reference[1] in ins.get_table_names())
Ejemplo n.º 5
0
    def test_store_raster(self):
        raster_output = ComplexOutput('raster',
                                      'Raster output',
                                      supported_formats=[FORMATS.GEOTIFF])
        raster_output.file = get_raster_file()
        raster_output.output_format = FORMATS.GEOTIFF

        store_raster = self.storage.store(raster_output)

        assert len(store_raster) == 3
        assert store_raster[0] == STORE_TYPE.DB
        assert isinstance(store_raster[1], str)
        assert isinstance(store_raster[2], str)

        # Parse reference into path to db and table
        reference = store_raster[2].rsplit(".", 1)

        db_url = "sqlite:///{}".format(reference[0])
        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)

        assert (reference[1] + "_rasters") in ins.get_table_names()
Ejemplo n.º 6
0
    def test_store_raster(self):
        raster_output = ComplexOutput('raster',
                                      'Raster output',
                                      supported_formats=[FORMATS.GEOTIFF])
        raster_output.file = get_raster_file()
        raster_output.output_format = FORMATS.GEOTIFF

        store_raster = self.storage.store(raster_output)

        assert len(store_raster) == 3
        assert store_raster[0] == STORE_TYPE.DB
        assert isinstance(store_raster[1], str)
        assert isinstance(store_raster[2], str)

        # Parse reference into dbname, schema and table
        reference = store_raster[2].split(".")

        db_url = "postgresql://{}:{}@{}:{}/{}".format(reference[0],
                                                      self.password, self.host,
                                                      self.port, self.user)
        engine = create_engine(db_url)
        # check if table exists
        ins = inspect(engine)
        assert (reference[2] in ins.get_table_names(schema=reference[1]))
Ejemplo n.º 7
0
 def test_store(self):
     vector_output = ComplexOutput('vector',
                                   'Vector output',
                                   supported_formats=[FORMATS.GML])
     vector_output.file = get_vector_file()
     assert not self.storage.store("some data")