~lutostag/ubuntu/utopic/maas/1.5.2

« back to all changes in this revision

Viewing changes to src/provisioningserver/testing/fakecobbler.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-15 18:14:08 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120315181408-zgl94hzo0x4n99an
Tags: 0.1+bzr295+dfsg-0ubuntu2
* debian/patches:
  - 01-fix-database-settings.patch: Update to set PSERV_URL.
  - 02-pserv-config.patch: Set port to 8001.
* debian/maas.postinst: Run maas-import-isos on install.
* debian/control: Depends on rabbitmq-server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
__metaclass__ = type
12
12
__all__ = [
 
13
    'fake_auth_failure_string',
 
14
    'fake_object_not_found_string',
 
15
    'fake_token',
13
16
    'FakeCobbler',
14
17
    'FakeTwistedProxy',
15
 
    'fake_token',
16
18
    'make_fake_cobbler_session',
17
19
    ]
18
20
 
35
37
unique_ints = count(randint(0, 99999))
36
38
 
37
39
 
 
40
def fake_auth_failure_string(token):
 
41
    """Fake a Cobbler authentication failure fault string for `token`."""
 
42
    return "<class 'cobbler.exceptions.CX'>:'invalid token: %s'" % token
 
43
 
 
44
 
 
45
def fake_object_not_found_string(object_type, object_name):
 
46
    """Fake a Cobbler unknown object fault string."""
 
47
    return (
 
48
        "<class 'cobbler.cexceptions.CX'>:'internal error, "
 
49
        "unknown %s name %s'" % (object_type, object_name))
 
50
 
 
51
 
38
52
def fake_token(user=None, custom_id=None):
39
53
    """Make up a fake auth token.
40
54
 
127
141
 
128
142
    def _check_token(self, token):
129
143
        if token not in self.tokens:
130
 
            raise Fault(1, "invalid token: %s" % token)
 
144
            raise Fault(1, fake_auth_failure_string(token))
131
145
 
132
146
    def _raise_bad_handle(self, object_type, handle):
133
147
        raise Fault(1, "Invalid %s handle: %s" % (object_type, handle))
205
219
        if handle is None:
206
220
            handle = self._get_handle_if_present(None, object_type, name)
207
221
        if handle is None:
208
 
            raise Fault(1, "Unknown %s: %s." % (object_type, name))
 
222
            raise Fault(1, fake_object_not_found_string(object_type, name))
209
223
        return handle
210
224
 
211
225
    def _api_find_objects(self, object_type, criteria):