Example #1
0
    def test_location(self):
        configuration.CONFIG.set('server', 'outputpath', self.tmp_dir)
        storage = FileStorageBuilder().build()
        file_name = 'test.txt'
        loc = storage.location(file_name)

        self.assertEqual(self.tmp_dir + '/test.txt', loc)
Example #2
0
    def test_write(self):
        configuration.CONFIG.set('server', 'outputpath', self.tmp_dir)
        configuration.CONFIG.set('server', 'outputurl',
                                 'file://' + self.tmp_dir)
        storage = FileStorageBuilder().build()
        output = ComplexOutput('testme',
                               'Test',
                               supported_formats=[FORMATS.TEXT],
                               workdir=self.tmp_dir)
        output.data = "Hello World!"
        url = storage.write(output.data, 'foo.txt')

        self.assertEqual(url, 'file://' + self.tmp_dir + '/foo.txt')
        with open(self.tmp_dir + '/foo.txt') as f:
            self.assertEqual(f.read(), "Hello World!")
Example #3
0
    def test_store(self):
        configuration.CONFIG.set('server', 'outputpath', self.tmp_dir)
        storage = FileStorageBuilder().build()
        output = ComplexOutput('testme',
                               'Test',
                               supported_formats=[FORMATS.TEXT],
                               workdir=self.tmp_dir)
        output.data = "Hello World!"
        store_type, store_str, url = storage.store(output)

        self.assertEqual(store_type, STORE_TYPE.PATH)
        self.assertEqual(store_str, 'input.txt')

        with open(self.tmp_dir + '/' + store_str) as f:
            self.assertEqual(f.read(), "Hello World!")
Example #4
0
    def test_url(self):
        configuration.CONFIG.set('server', 'outputpath', self.tmp_dir)
        configuration.CONFIG.set('server', 'outputurl',
                                 'file://' + self.tmp_dir)
        storage = FileStorageBuilder().build()
        output = ComplexOutput('testme',
                               'Test',
                               supported_formats=[FORMATS.TEXT],
                               workdir=self.tmp_dir)
        output.data = "Hello World!"
        url = storage.url(output)

        self.assertEqual('file://' + self.tmp_dir + '/input.txt', url)

        file_name = 'test.txt'
        url = storage.url(file_name)

        self.assertEqual('file://' + self.tmp_dir + '/test.txt', url)
Example #5
0
 def test_url_handler(self):
     wfsResource = 'http://demo.mapserver.org/cgi-bin/wfs?' \
                   'service=WFS&version=1.1.0&' \
                   'request=GetFeature&' \
                   'typename=continents&maxfeatures=2'
     self.complex_out.url = wfsResource
     self.complex_out.storage = FileStorageBuilder().build()
     url = self.complex_out.get_url()
     self.assertEqual('file', urlparse(url).scheme)
Example #6
0
 def test_build_output_name(self):
     storage = FileStorageBuilder().build()
     output = ComplexOutput('testme',
                            'Test',
                            supported_formats=[FORMATS.TEXT],
                            workdir=self.tmp_dir)
     output.data = "Hello World!"
     output_name, suffix = _build_output_name(output)
     self.assertEqual(output.file, self.tmp_dir + '/input.txt')
     self.assertEqual(output_name, 'input.txt')
     self.assertEqual(suffix, '.txt')
Example #7
0
    def _json_reference(self, data):
        """Return Reference node
        """
        data["type"] = "reference"

        # get_url will create the file and return the url for it
        if self.prop == 'url':
            data["href"] = self.url
        elif self.prop is not None:
            self.storage = FileStorageBuilder().build()
            data["href"] = self.get_url()

        return data