def test_unmarshal_single_server(self): decorator = api.reroute_compute("foo") self.assertEquals(decorator.unmarshall_result([]), {}) self.assertEquals(decorator.unmarshall_result([FakeResource(dict(a=1, b=2))]), dict(server=dict(a=1, b=2))) self.assertEquals(decorator.unmarshall_result([FakeResource(dict(a=1, _b=2))]), dict(server=dict(a=1))) self.assertEquals(decorator.unmarshall_result([FakeResource(dict(a=1, manager=2))]), dict(server=dict(a=1))) self.assertEquals(decorator.unmarshall_result([FakeResource(dict(_a=1, manager=2))]), dict(server={}))
def test_get_collection_context_and_id(self): decorator = api.reroute_compute("foo") self.assertEquals(decorator.get_collection_context_and_id( (None, 10, 20), {}), ("servers", 10, 20)) self.assertEquals(decorator.get_collection_context_and_id( (None, 11,), dict(instance_id=21)), ("servers", 11, 21)) self.assertEquals(decorator.get_collection_context_and_id( (None,), dict(context=12, instance_id=22)), ("servers", 12, 22))
def test_get_collection_context_and_id(self): decorator = api.reroute_compute("foo") self.assertEquals( decorator.get_collection_context_and_id((None, 10, 20), {}), ("servers", 10, 20)) self.assertEquals( decorator.get_collection_context_and_id(( None, 11, ), dict(instance_id=21)), ("servers", 11, 21)) self.assertEquals( decorator.get_collection_context_and_id((None, ), dict(context=12, instance_id=22)), ("servers", 12, 22))
def test_unmarshal_single_server(self): decorator = api.reroute_compute("foo") self.assertEquals(decorator.unmarshall_result([]), {}) self.assertEquals( decorator.unmarshall_result([ FakeResource(dict(a=1, b=2)), ]), dict(server=dict(a=1, b=2))) self.assertEquals( decorator.unmarshall_result([ FakeResource(dict(a=1, _b=2)), ]), dict(server=dict(a=1, ))) self.assertEquals( decorator.unmarshall_result([ FakeResource(dict(a=1, manager=2)), ]), dict(server=dict(a=1, ))) self.assertEquals( decorator.unmarshall_result([ FakeResource(dict(_a=1, manager=2)), ]), dict(server={}))