MapServer / MapServer-import

3 stars 2 forks source link

clone method of mapObj not properly copying outputformats #510

Closed tbonfort closed 12 years ago

tbonfort commented 12 years ago

Reporter: sgillies@frii.com Date: 2003/12/08 - 04:40

Michael Schulz reported this:

After investigating more, i found mapObj.clone() works for 
explicitly defined outputformats, but not for default 
outputformats only defined by mapfile keyword imagetype.
This is mapserver related then.
But still, a zmap instance created from a mapfile with a 
explicit outputformat definition "looses" this defintion
when
using the session_draw method. zmap view works with the 
defined outputformat.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2003/12/08 - 04:41

Accepted, will write tests to reproduce the bug and then start to fix it.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2003/12/08 - 21:04

I can reproduce the reported bug.  This is the test

class ClonedMapOutputFormatTestCase(unittest.TestCase):
    """This test case is developed to address MapServer bug 510"""

    def setUp(self):
        self.mapobj1 = mapObj(testMapfile)
    def tearDown(self):
        self.mapobj1 = None
    def testClonedMapKeepsOutputFormat(self):
        self.mapobj1.setImageType('image/jpeg')
        assert self.mapobj1.outputformat.mimetype == 'image/jpeg'
        mapobj_clone = self.mapobj1.clone()
        assert mapobj_clone.thisown == 1
        mime = mapobj_clone.outputformat.mimetype
        assert mime == 'image/jpeg', mime

and here is the result of the test:

FAIL: testClonedMapKeepsOutputFormat (__main__.ClonedMapOutputFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/testMapScript.py", line 645, in testClonedMapKeepsOutputFormat
    assert mime == 'image/jpeg', mime
AssertionError: image/png

I've a good idea on how to fix msCopyMap.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2003/12/09 - 17:18


Fixed.  Here are the tests.  The first tests that the cloned map's
outputformat has the same mimetype as the original.  The second
tests that set options have been cloned.  Both pass.  Note that
I had to write a getOption method for outputFormatObj in order to
properly test.  Changes are committed to 4.0 and 4.1 branches.

class ClonedMapOutputFormatTestCase(unittest.TestCase):
    """This test case is developed to address MapServer bug 510"""
    def setUp(self):
        self.mapobj1 = mapObj(testMapfile)
    def tearDown(self):
        self.mapobj1 = None
    def testClonedMapKeepsOutputFormat(self):
        self.mapobj1.setImageType('image/jpeg')
        assert self.mapobj1.outputformat.mimetype == 'image/jpeg'
        mapobj_clone = self.mapobj1.clone()
        assert mapobj_clone.thisown == 1
        mime = mapobj_clone.outputformat.mimetype
        assert mime == 'image/jpeg', mime
    def testClonedMapKeepsModifiedOutputFormat(self):
        self.mapobj1.setImageType('image/jpeg')
        self.mapobj1.outputformat.setOption('QUALITY','90');
        assert self.mapobj1.outputformat.mimetype == 'image/jpeg'
        iquality = self.mapobj1.outputformat.getOption('QUALITY')
        assert iquality == '90'
        mapobj_clone = self.mapobj1.clone()
        assert mapobj_clone.thisown == 1
        quality = mapobj_clone.outputformat.getOption('QUALITY')
        assert quality == iquality, quality