[Zope3-checkins] CVS: Zope3/src/zope/fssync/server/tests - __init__.py:1.1 test_syncer.py:1.1

Fred L. Drake, Jr. fred at zope.com
Tue Jan 13 17:28:54 EST 2004


Update of /cvs-repository/Zope3/src/zope/fssync/server/tests
In directory cvs.zope.org:/tmp/cvs-serv16405/src/zope/fssync/server/tests

Added Files:
	__init__.py test_syncer.py 
Log Message:
- move the fssync "Syner" and serialization adapter interfaces into
  the zope.fssync.server package

- remove annotations() from IObjectEntry, implementations
  (should be near-free since these should not used anymore)

- make the syncer, checker, committer parameterizable with three
  functions that operate on content objects:
  - get the serialization adapter
  - get the annotations adapter
  - get the object identifier


=== Added File Zope3/src/zope/fssync/server/tests/__init__.py ===
#
# This file is necessary to make this directory a package.


=== Added File Zope3/src/zope/fssync/server/tests/test_syncer.py ===
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Tests for the general synchronizer."""

import os
import shutil
import tempfile
import unittest

from zope.fssync.server import syncer, interfaces
from zope.interface import implements


class MyError(Exception):
    pass


class MySerializer:

    implements(interfaces.IObjectDirectory)

    def __init__(self, context):
        pass

    def extra(self):
        return None

    def typeIdentifier(self):
        return "good.type"

    def factory(self):
        return "good.factory"

    def contents(self):
        return {}


def raise_error(obj):
    raise MyError


class SyncerTestCase(unittest.TestCase):

    def setUp(self):
        self.location = tempfile.mktemp()
        os.mkdir(self.location)

    def tearDown(self):
        shutil.rmtree(self.location)

    def test_calling_getObjectId(self):
        s = syncer.Syncer(raise_error, MySerializer)
        self.assertRaises(MyError,
                          s.toFS, 42, "foo", self.location)

    def test_calling_getSerializer(self):
        s = syncer.Syncer(lambda obj: "/foo/bar", raise_error)
        self.assertRaises(MyError,
                          s.toFS, 42, "foo", self.location)

    def test_calling_both(self):
        s = syncer.Syncer(lambda obj: "/foo/bar", MySerializer)
        s.toFS(42, "foo", self.location)

    def test_calling_getAnnotations(self):
        s = syncer.Syncer(lambda obj: "/foo/bar", MySerializer,
                          raise_error)
        self.assertRaises(MyError,
                          s.toFS, 42, "foo", self.location)


def test_suite():
    return unittest.makeSuite(SyncerTestCase)




More information about the Zope3-Checkins mailing list