def test_destroy(self, mock_kp_destroy): keypair_obj = keypair.KeyPair(context=self.context) keypair_obj.id = 123 keypair_obj.user_id = 'fake-user' keypair_obj.name = 'foo-keypair' keypair_obj.destroy() mock_kp_destroy.assert_called_once_with( self.context, 'fake-user', 'foo-keypair')
def test_destroy(self): self.mox.StubOutWithMock(db, 'key_pair_destroy') db.key_pair_destroy(self.context, 'fake-user', 'foo-keypair') self.mox.ReplayAll() keypair_obj = keypair.KeyPair() keypair_obj.id = 123 keypair_obj.user_id = 'fake-user' keypair_obj.name = 'foo-keypair' keypair_obj.destroy(self.context)
def test_recreate_fails(self, mock_kp_create): mock_kp_create.return_value = fake_keypair keypair_obj = keypair.KeyPair(context=self.context) keypair_obj.name = 'foo-keypair' keypair_obj.public_key = 'keydata' keypair_obj.create() self.assertRaises(exception.ObjectActionError, keypair_obj.create) mock_kp_create.assert_called_once_with(self.context, {'name': 'foo-keypair', 'public_key': 'keydata'})
def test_create(self, mock_kp_create): mock_kp_create.return_value = fake_keypair keypair_obj = keypair.KeyPair(context=self.context) keypair_obj.name = 'foo-keypair' keypair_obj.public_key = 'keydata' keypair_obj.create() self.compare_obj(keypair_obj, fake_keypair) mock_kp_create.assert_called_once_with(self.context, {'name': 'foo-keypair', 'public_key': 'keydata'})
def test_create(self): self.mox.StubOutWithMock(db, 'key_pair_create') db.key_pair_create(self.context, {'name': 'foo-keypair', 'public_key': 'keydata'}).AndReturn(fake_keypair) self.mox.ReplayAll() keypair_obj = keypair.KeyPair() keypair_obj.name = 'foo-keypair' keypair_obj.public_key = 'keydata' keypair_obj.create(self.context) self._compare(keypair_obj, fake_keypair)
def test_recreate_fails(self): self.mox.StubOutWithMock(db, 'key_pair_create') db.key_pair_create(self.context, {'name': 'foo-keypair', 'public_key': 'keydata'}).AndReturn(fake_keypair) self.mox.ReplayAll() keypair_obj = keypair.KeyPair() keypair_obj.name = 'foo-keypair' keypair_obj.public_key = 'keydata' keypair_obj.create(self.context) self.assertRaises(exception.ObjectActionError, keypair_obj.create, self.context)
def test_obj_make_compatible(self): keypair_obj = keypair.KeyPair(context=self.context) fake_keypair_copy = dict(fake_keypair) keypair_obj.obj_make_compatible(fake_keypair_copy, '1.1') self.assertNotIn('type', fake_keypair_copy)