18
18
from provisioningserver import cobblerclient
19
19
from provisioningserver.testing.fakecobbler import (
20
20
fake_auth_failure_string,
21
fake_object_not_found_string,
23
24
from testtools.content import text_content
255
256
cobblerclient.looks_like_auth_expiry(make_auth_failure()))
258
def test_looks_like_object_not_found_for_regular_exception(self):
260
cobblerclient.looks_like_object_not_found(RuntimeError("Error")))
262
def test_looks_like_object_not_found_for_other_Fault(self):
264
cobblerclient.looks_like_object_not_found(
265
Fault(1, "Missing sprocket")))
267
def test_looks_like_object_not_found_recognizes_object_not_found(self):
268
error = Fault(1, fake_object_not_found_string("distro", "bob"))
270
cobblerclient.looks_like_object_not_found(error))
258
273
def test_call_reauthenticates_and_retries_on_auth_failure(self):
259
274
# If a call triggers an authentication error, call()
416
431
session, 'incomplete_system', {})
434
def test_new_attempts_edit_before_creating_new(self):
435
# CobblerObject.new always attempts an extended edit operation on the
436
# given object first, following by an add should the object not yet
438
session = make_recording_session()
439
not_found_string = fake_object_not_found_string("system", "carcass")
440
not_found = Fault(1, not_found_string)
441
session.proxy.set_return_values([not_found, True])
442
yield cobblerclient.CobblerSystem.new(
443
session, "carcass", {"profile": "heartwork"})
445
# First an edit is attempted...
446
("xapi_object_edit", "system", "carcass", "edit",
447
{"name": "carcass", "profile": "heartwork"},
449
# Followed by an add.
450
("xapi_object_edit", "system", "carcass", "add",
451
{"name": "carcass", "profile": "heartwork"},
454
self.assertEqual(expected_calls, session.proxy.calls)
419
457
def test_modify(self):
420
458
session = make_recording_session()
421
459
session.proxy.set_return_values([True])