Part of canonical.librarian.ftests.harness View In Hierarchy
Set up librarian servers for use by functional tests.
>>> from urllib import urlopen >>> from canonical.config import config
>>> librarian_url = "http://%s:%d" % ( ... config.librarian.download_host, ... config.librarian.download_port) >>> restricted_librarian_url = "http://%s:%d" % ( ... config.librarian.restricted_download_host, ... config.librarian.restricted_download_port)
>>> LibrarianTestSetup().setUp()
Set a socket timeout, so that this test cannot hang indefinitely.
>>> import socket >>> print socket.getdefaulttimeout() None >>> socket.setdefaulttimeout(1)
After setUp() is called, two librarian instances are started. The regular one:
>>> 'Copyright' in urlopen(librarian_url).read() True
And the restricted one:
>>> 'Copyright' in urlopen(restricted_librarian_url).read() True
The librarian root is also available.
>>> import os >>> os.path.isdir(config.librarian_server.root) True
After tearDown() is called, both instances are shut down:
>>> LibrarianTestSetup().tearDown()
>>> urlopen(librarian_url).read() Traceback (most recent call last): ... IOError: ...
>>> urlopen(restricted_librarian_url).read() Traceback (most recent call last): ... IOError: ...
The root directory was removed:
>>> os.path.exists(config.librarian_server.root) False
That fixture can be started and stopped multiple time in succession:
>>> LibrarianTestSetup().setUp() >>> 'Copyright' in urlopen(librarian_url).read() True
Tidy up.
>>> LibrarianTestSetup().tearDown() >>> socket.setdefaulttimeout(None)
Method | setUp | Start both librarian instances. |
Method | tearDown | Shut downs both librarian instances. |
Method | clear | Clear all files from the Librarian |
Method | root | The root directory for the librarian file repository. |
Method | setUpRoot | Create the librarian root archive. |
Method | tearDownRoot | Remove the librarian root archive. |