def setUp(self):
     creds = Credentials()
     self.novaservice = NovaClient(creds.get_nova_creds())
     self.fc = FakeInstance()
     self.novaservice._check_keypair = Mock(return_value=True)
     self.novaservice._check_image = Mock(return_value=DEF_IMAGE_ID)
     self.novaservice._check_flavor = Mock(return_value=DEF_FLAVOR_ID)
class TestNovaClient(unittest.TestCase):
    def setUp(self):
        creds = Credentials()
        self.novaservice = NovaClient(creds.get_nova_creds())
        self.fc = FakeInstance()
        self.novaservice._check_keypair = Mock(return_value=True)
        self.novaservice._check_image = Mock(return_value=DEF_IMAGE_ID)
        self.novaservice._check_flavor = Mock(return_value=DEF_FLAVOR_ID)

    def test_create_instance(self):
        self.novaservice.nc.servers.create = Mock(return_value=self.fc)
        expected = '12345'
        self.assertEqual(self.novaservice.create_new_instance(
            DEF_NAME, DEF_IMAGE_ID, DEF_FLAVOR_ID, SSH_MY_KEY), expected)