diff options
author | Bin Sun <bins@vmware.com> | 2018-04-12 10:33:37 +0800 |
---|---|---|
committer | Bin Sun <bins@vmware.com> | 2018-04-12 10:35:35 +0800 |
commit | 4632a6e222e089aa47bb6e8439c908d43c204ede (patch) | |
tree | bcfc22317409880d47de9af5ccca1aa1a45a913b | |
parent | 6f59c780573ef4380871cb7de941b3b9150d1a98 (diff) |
Add fake create token test
Change-Id: Ie3760f34aa880be0119e21d857f49a1541fbf926
Issue-ID: MULTICLOUD-199
Signed-off-by: Bin Sun <bins@vmware.com>
-rw-r--r-- | vio/vio/tests/test_fake_identity_view.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vio/vio/tests/test_fake_identity_view.py b/vio/vio/tests/test_fake_identity_view.py index 7d802ff..f8c673e 100644 --- a/vio/vio/tests/test_fake_identity_view.py +++ b/vio/vio/tests/test_fake_identity_view.py @@ -12,6 +12,7 @@ import mock import unittest +import json from vio.swagger.views.fakeplugin.identity import views from vio.swagger.views.fakeplugin.fakeData import fakeResponse @@ -52,3 +53,15 @@ class TestFakeToken(unittest.TestCase): } resp = self.view.get(mock.Mock()) self.assertEqual(200, resp.status_code) + + @mock.patch("requests.post") + @mock.patch.object(fakeResponse, "keystone_token") + def test_create_token(self, mock_keystone_token, mock_post): + req = mock.Mock() + req.get_full_path.return_value = "identity/v3/auth/tokens" + req.body = json.dumps( + {"auth": {"scope": {"project": {"id": "1234abcd"}}}}) + mock_keystone_token.return_value = { + "token": {"value": Token}} + resp = self.view.post(req) + self.assertEqual(201, resp.status_code) |