Example #1
0
    def test_profile_get(self, mock_find):
        x_obj = mock.Mock()
        mock_find.return_value = x_obj
        x_obj.to_dict.return_value = {'foo': 'bar'}
        req = vorp.ProfileGetRequest(identity='FAKE_PROFILE')

        result = self.eng.profile_get(self.ctx, req.obj_to_primitive())

        self.assertEqual({'foo': 'bar'}, result)
        mock_find.assert_called_once_with(self.ctx, 'FAKE_PROFILE')
Example #2
0
    def test_profile_get_not_found(self, mock_find):
        mock_find.side_effect = exc.ResourceNotFound(type='profile',
                                                     id='Bogus')
        req = vorp.ProfileGetRequest(identity='Bogus')
        ex = self.assertRaises(rpc.ExpectedException, self.eng.profile_get,
                               self.ctx, req.obj_to_primitive())

        self.assertEqual(exc.ResourceNotFound, ex.exc_info[0])
        self.assertEqual("The profile 'Bogus' could not be found.",
                         six.text_type(ex.exc_info[1]))
        mock_find.assert_called_once_with(self.ctx, 'Bogus')
Example #3
0
 def test_profile_get(self):
     sot = profiles.ProfileGetRequest(identity='FAKE_ID')
     self.assertEqual('FAKE_ID', sot.identity)