Exemplo n.º 1
0
class TestImageFile(unittest.TestCase):
    def setUp(self):
        # ugly: need to save the old App.config configuration value since
        # ImageFile might read it and trigger setting it to the default value
        self.oldcfg = App.config._config
        self.warningshook = WarningsHook()
        self.warningshook.install()

    def tearDown(self):
        self.warningshook.uninstall()
        # ugly: need to restore configuration, or lack thereof
        App.config._config = self.oldcfg

    def test_warn_on_software_home_default(self):
        App.ImageFile.ImageFile('App/www/zopelogo.png')
        self.assertEqual(self.warningshook.warnings.pop()[0],
                         App.ImageFile.NON_PREFIX_WARNING)

    def test_no_warn_on_absolute_path(self):
        path = os.path.join(os.path.dirname(App.__file__), 'www',
                            'zopelogo.png')
        App.ImageFile.ImageFile(path)
        self.assertFalse(self.warningshook.warnings)

    def test_no_warn_on_path_as_prefix(self):
        prefix = os.path.dirname(App.__file__)
        App.ImageFile.ImageFile('www/zopelogo.png', prefix)
        self.assertFalse(self.warningshook.warnings)

    def test_no_warn_on_namespace_as_prefix(self):
        # same as calling globals() inside the App module
        prefix = App.__dict__
        App.ImageFile.ImageFile('www/zopelogo.png', prefix)
        self.assertFalse(self.warningshook.warnings)
Exemplo n.º 2
0
class TestImageFile(unittest.TestCase):

    def setUp(self):
        # ugly: need to save the old App.config configuration value since
        # ImageFile might read it and trigger setting it to the default value 
        self.oldcfg = App.config._config
        self.warningshook = WarningsHook()
        self.warningshook.install()

    def tearDown(self):
        self.warningshook.uninstall()
        # ugly: need to restore configuration, or lack thereof
        App.config._config = self.oldcfg

    def test_warn_on_software_home_default(self):
        App.ImageFile.ImageFile('App/www/zopelogo.jpg')
        self.assertEquals(self.warningshook.warnings.pop()[0],
                          App.ImageFile.NON_PREFIX_WARNING)

    def test_no_warn_on_absolute_path(self):
        path = os.path.join(os.path.dirname(App.__file__),
                            'www','zopelogo.jpg')
        App.ImageFile.ImageFile(path)
        self.assertFalse(self.warningshook.warnings)

    def test_no_warn_on_path_as_prefix(self):
        prefix = os.path.dirname(App.__file__)
        App.ImageFile.ImageFile('www/zopelogo.jpg', prefix)
        self.assertFalse(self.warningshook.warnings)

    def test_no_warn_on_namespace_as_prefix(self):
        prefix = App.__dict__ # same as calling globals() inside the App module
        App.ImageFile.ImageFile('www/zopelogo.jpg', prefix)
        self.assertFalse(self.warningshook.warnings)
Exemplo n.º 3
0
class TestCatalogReturnAll(CatalogBase, unittest.TestCase):
    def setUp(self):
        self.warningshook = WarningsHook()
        self.warningshook.install()
        self._catalog = self._makeOne()

    def testEmptyMappingReturnsAll(self):
        col1 = FieldIndex("col1")
        self._catalog.addIndex("col1", col1)
        for x in range(0, 10):
            self._catalog.catalogObject(dummy(x), repr(x))
        self.assertEqual(len(self._catalog), 10)
        length = len(self._catalog({}))
        self.assertEqual(length, 10)

    def tearDown(self):
        CatalogBase.tearDown(self)
        self.warningshook.uninstall()
Exemplo n.º 4
0
class TestCatalogReturnAll(CatalogBase, unittest.TestCase):
    def setUp(self):
        self.warningshook = WarningsHook()
        self.warningshook.install()
        self._catalog = self._makeOne()

    def testEmptyMappingReturnsAll(self):
        col1 = FieldIndex('col1')
        self._catalog.addIndex('col1', col1)
        for x in range(0, 10):
            self._catalog.catalogObject(dummy(x), repr(x))
        self.assertEqual(len(self._catalog), 10)
        length = len(self._catalog({}))
        self.assertEqual(length, 10)

    def tearDown(self):
        CatalogBase.tearDown(self)
        self.warningshook.uninstall()
Exemplo n.º 5
0
class TestCatalogReturnAll(unittest.TestCase):
    def _make_one(self):
        from Products.ZCatalog.Catalog import Catalog
        return Catalog()

    def setUp(self):
        self.warningshook = WarningsHook()
        self.warningshook.install()

    def tearDown(self):
        self.warningshook.uninstall()

    def testEmptyMappingReturnsAll(self):
        catalog = self._make_one()
        col1 = FieldIndex('col1')
        catalog.addIndex('col1', col1)
        for x in range(0, 10):
            catalog.catalogObject(dummy(x), repr(x))
        self.assertEqual(len(catalog), 10)
        length = len(catalog({}))
        self.assertEqual(length, 10)
class TestCatalogReturnAll(unittest.TestCase):

    def _make_one(self):
        from Products.ZCatalog.Catalog import Catalog
        return Catalog()

    def setUp(self):
        self.warningshook = WarningsHook()
        self.warningshook.install()

    def tearDown(self):
        self.warningshook.uninstall()

    def testEmptyMappingReturnsAll(self):
        catalog = self._make_one()
        col1 = FieldIndex('col1')
        catalog.addIndex('col1', col1)
        for x in range(0, 10):
            catalog.catalogObject(dummy(x), repr(x))
        self.assertEqual(len(catalog), 10)
        length = len(catalog({}))
        self.assertEqual(length, 10)
Exemplo n.º 7
0
 def setUp(self):
     # ugly: need to save the old App.config configuration value since
     # ImageFile might read it and trigger setting it to the default value
     self.oldcfg = App.config._config
     self.warningshook = WarningsHook()
     self.warningshook.install()
Exemplo n.º 8
0
 def setUp(self):
     self.warningshook = WarningsHook()
     self.warningshook.install()
     self._catalog = self._makeOne()
Exemplo n.º 9
0
 def setUp(self):
     self.warningshook = WarningsHook()
     self.warningshook.install()
 def setUp(self):
     self.warningshook = WarningsHook()
     self.warningshook.install()
Exemplo n.º 11
0
 def setUp(self):
     # ugly: need to save the old App.config configuration value since
     # ImageFile might read it and trigger setting it to the default value 
     self.oldcfg = App.config._config
     self.warningshook = WarningsHook()
     self.warningshook.install()