~ubuntu-branches/ubuntu/quantal/python-keystoneclient/quantal-updates

« back to all changes in this revision

Viewing changes to tests/v2_0/test_services.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-03-26 14:01:05 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120326140105-c9ddds5lbchco3ia
Tags: 2012.1~rc1-0ubuntu1
New upstream release. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
class ServiceTests(utils.TestCase):
11
11
    def setUp(self):
12
12
        super(ServiceTests, self).setUp()
13
 
        self.TEST_REQUEST_HEADERS = {'X-Auth-Token': 'aToken',
14
 
                                     'User-Agent': 'python-keystoneclient'}
15
 
        self.TEST_POST_HEADERS = {'Content-Type': 'application/json',
16
 
                                  'X-Auth-Token': 'aToken',
17
 
                                  'User-Agent': 'python-keystoneclient'}
18
 
        self.TEST_SERVICES = {"OS-KSADM:services": {
19
 
                                "values": [
20
 
                                  {
21
 
                                    "name": "nova",
22
 
                                    "type": "compute",
23
 
                                    "description": "Nova-compatible service.",
24
 
                                    "id": 1
25
 
                                  },
26
 
                                  {
27
 
                                    "name": "keystone",
28
 
                                    "type": "identity",
29
 
                                    "description": ("Keystone-compatible "
30
 
                                                    "service."),
31
 
                                    "id": 2
32
 
                                  }
33
 
                                 ]
34
 
                                }
35
 
                            }
 
13
        self.TEST_REQUEST_HEADERS = {
 
14
            'X-Auth-Token': 'aToken',
 
15
            'User-Agent': 'python-keystoneclient',
 
16
            }
 
17
        self.TEST_POST_HEADERS = {
 
18
            'Content-Type': 'application/json',
 
19
            'X-Auth-Token': 'aToken',
 
20
            'User-Agent': 'python-keystoneclient',
 
21
            }
 
22
        self.TEST_SERVICES = {
 
23
            "OS-KSADM:services": {
 
24
                "values": [
 
25
                    {
 
26
                        "name": "nova",
 
27
                        "type": "compute",
 
28
                        "description": "Nova-compatible service.",
 
29
                        "id": 1
 
30
                        },
 
31
                    {
 
32
                        "name": "keystone",
 
33
                        "type": "identity",
 
34
                        "description": "Keystone-compatible service.",
 
35
                        "id": 2
 
36
                        },
 
37
                    ],
 
38
                },
 
39
            }
36
40
 
37
41
    def test_create(self):
38
 
        req_body = {"OS-KSADM:service": {"name": "swift",
39
 
                                "type": "object-store",
40
 
                                "description": "Swift-compatible service."}}
41
 
        resp_body = {"OS-KSADM:service": {"name": "swift",
42
 
                                "type": "object-store",
43
 
                                "description": "Swift-compatible service.",
44
 
                                "id": 3}}
 
42
        req_body = {
 
43
            "OS-KSADM:service": {
 
44
                "name": "swift",
 
45
                "type": "object-store",
 
46
                "description": "Swift-compatible service.",
 
47
                }
 
48
            }
 
49
        resp_body = {
 
50
            "OS-KSADM:service": {
 
51
                "name": "swift",
 
52
                "type": "object-store",
 
53
                "description": "Swift-compatible service.",
 
54
                "id": 3,
 
55
                }
 
56
            }
45
57
        resp = httplib2.Response({
46
58
            "status": 200,
47
59
            "body": json.dumps(resp_body),
66
78
    def test_delete(self):
67
79
        resp = httplib2.Response({
68
80
            "status": 200,
69
 
            "body": ""
 
81
            "body": "",
70
82
            })
71
83
        httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
72
84
                              'v2.0/OS-KSADM/services/1'),
78
90
        self.client.services.delete(1)
79
91
 
80
92
    def test_get(self):
 
93
        test_services = self.TEST_SERVICES['OS-KSADM:services']['values'][0]
81
94
        resp = httplib2.Response({
82
95
            "status": 200,
83
 
            "body": json.dumps({'OS-KSADM:service':
84
 
                self.TEST_SERVICES['OS-KSADM:services']['values'][0]}),
 
96
            "body": json.dumps({'OS-KSADM:service': test_services}),
85
97
            })
86
98
        httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
87
99
                              'v2.0/OS-KSADM/services/1'),
110
122
        self.mox.ReplayAll()
111
123
 
112
124
        service_list = self.client.services.list()
113
 
        [self.assertTrue(isinstance(r, services.Service)) \
114
 
                for r in service_list]
 
125
        [self.assertTrue(isinstance(r, services.Service))
 
126
         for r in service_list]