add in unit tests

This commit is contained in:
Anthony Young 2010-12-28 17:42:33 -08:00
parent e4c1fa91e0
commit 35638077a1
3 changed files with 25 additions and 0 deletions

View File

@ -150,6 +150,19 @@ class CloudTestCase(test.TestCase):
greenthread.sleep(0.3)
rv = yield self.cloud.terminate_instances(self.context, [instance_id])
def test_ajax_console(self):
kwargs = {'image_id': image_id }
rv = yield self.cloud.run_instances(self.context, **kwargs)
instance_id = rv['instancesSet'][0]['instanceId']
output = yield self.cloud.get_console_output(context=self.context,
instance_id=[instance_id])
self.assertEquals(b64decode(output['output']),
'http://fakeajaxconsole.com/?token=FAKETOKEN')
# TODO(soren): We need this until we can stop polling in the rpc code
# for unit tests.
greenthread.sleep(0.3)
rv = yield self.cloud.terminate_instances(self.context, [instance_id])
def test_key_generation(self):
result = self._create_key('test')
private_key = result['private_key']

View File

@ -153,6 +153,16 @@ class ComputeTestCase(test.TestCase):
self.assert_(console)
self.compute.terminate_instance(self.context, instance_id)
def test_ajax_console(self):
"""Make sure we can get console output from instance"""
instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id)
console = self.compute.get_ajax_console(self.context,
instance_id)
self.assert_(console)
self.compute.terminate_instance(self.context, instance_id)
def test_run_instance_existing(self):
"""Ensure failure when running an instance that already exists"""
instance_id = self._create_instance()

View File

@ -260,6 +260,8 @@ class FakeConnection(object):
def get_console_output(self, instance):
return 'FAKE CONSOLE OUTPUT'
def get_ajax_console(self, instance):
return 'http://fakeajaxconsole.com/?token=FAKETOKEN'
class FakeInstance(object):