~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_server.py

  • Committer: Vincent Ladeuil
  • Date: 2010-02-09 17:13:04 UTC
  • mto: (5029.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5030.
  • Revision ID: v.ladeuil+lp@free.fr-20100209171304-2ppoju422x02s7fm
Move MemoryServer to bzrlib.tests.test_server

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        return urlutils.local_path_to_url('')
69
69
 
70
70
 
 
71
class MemoryServer(Server):
 
72
    """Server for the MemoryTransport for testing with."""
 
73
 
 
74
    def start_server(self):
 
75
        self._dirs = {'/':None}
 
76
        self._files = {}
 
77
        self._locks = {}
 
78
        self._scheme = "memory+%s:///" % id(self)
 
79
        def memory_factory(url):
 
80
            from bzrlib.transport import memory
 
81
            result = memory.MemoryTransport(url)
 
82
            result._dirs = self._dirs
 
83
            result._files = self._files
 
84
            result._locks = self._locks
 
85
            return result
 
86
        self._memory_factory = memory_factory
 
87
        transport.register_transport(self._scheme, self._memory_factory)
 
88
 
 
89
    def stop_server(self):
 
90
        # unregister this server
 
91
        transport.unregister_transport(self._scheme, self._memory_factory)
 
92
 
 
93
    def get_url(self):
 
94
        """See bzrlib.transport.Server.get_url."""
 
95
        return self._scheme
 
96
 
 
97
 
71
98
class DecoratorServer(Server):
72
99
    """Server for the TransportDecorator for testing with.
73
100