How to use test_list_users method in tempest

Best Python code snippet using tempest_python

test_list_users_scenarios.py

Source:test_list_users_scenarios.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2#3# Copyright © 2012 New Dream Network, LLC (DreamHost)4#5# Author: Doug Hellmann <doug.hellmann@dreamhost.com>6# Julien Danjou <julien@danjou.info>7#8# Licensed under the Apache License, Version 2.0 (the "License"); you may9# not use this file except in compliance with the License. You may obtain10# a copy of the License at11#12# http://www.apache.org/licenses/LICENSE-2.013#14# Unless required by applicable law or agreed to in writing, software15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the17# License for the specific language governing permissions and limitations18# under the License.19"""Test listing users.20"""21import datetime22import logging23from ceilometer.publisher import utils24from ceilometer import sample25from ceilometer.tests import api as tests_api26from ceilometer.tests import db as tests_db27LOG = logging.getLogger(__name__)28class TestListEmptyUsers(tests_api.TestBase,29 tests_db.MixinTestsWithBackendScenarios):30 def test_empty(self):31 data = self.get('/users')32 self.assertEqual({'users': []}, data)33class TestListUsers(tests_api.TestBase,34 tests_db.MixinTestsWithBackendScenarios):35 def setUp(self):36 super(TestListUsers, self).setUp()37 sample1 = sample.Sample(38 'instance',39 'cumulative',40 'instance',41 1,42 'user-id',43 'project-id',44 'resource-id',45 timestamp=datetime.datetime(2012, 7, 2, 10, 40),46 resource_metadata={'display_name': 'test-server',47 'tag': 'self.sample',48 },49 source='test_list_users',50 )51 msg = utils.meter_message_from_counter(52 sample1,53 self.CONF.publisher.metering_secret,54 )55 self.conn.record_metering_data(msg)56 sample2 = sample.Sample(57 'instance',58 'cumulative',59 '',60 1,61 'user-id2',62 'project-id',63 'resource-id-alternate',64 timestamp=datetime.datetime(2012, 7, 2, 10, 41),65 resource_metadata={'display_name': 'test-server',66 'tag': 'self.sample2',67 },68 source='not-test',69 )70 msg2 = utils.meter_message_from_counter(71 sample2,72 self.CONF.publisher.metering_secret,73 )74 self.conn.record_metering_data(msg2)75 def test_users(self):76 data = self.get('/users')77 self.assertEqual(['user-id', 'user-id2'], data['users'])78 def test_users_non_admin(self):79 data = self.get('/users',80 headers={"X-Roles": "Member",81 "X-User-Id": "user-id",82 "X-Project-Id": "project-id"})83 self.assertEqual(['user-id'], data['users'])84 def test_with_source(self):85 data = self.get('/sources/test_list_users/users')86 self.assertEqual(data['users'], ['user-id'])87 def test_with_source_non_admin(self):88 data = self.get('/sources/test_list_users/users',89 headers={"X-Roles": "Member",90 "X-User-Id": "user-id",91 "X-Project-Id": "project-id"})...

Full Screen

Full Screen

test_list_projects_scenarios.py

Source:test_list_projects_scenarios.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2#3# Copyright © 2012 New Dream Network, LLC (DreamHost)4#5# Author: Doug Hellmann <doug.hellmann@dreamhost.com>6# Julien Danjou <julien@danjou.info>7#8# Licensed under the Apache License, Version 2.0 (the "License"); you may9# not use this file except in compliance with the License. You may obtain10# a copy of the License at11#12# http://www.apache.org/licenses/LICENSE-2.013#14# Unless required by applicable law or agreed to in writing, software15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the17# License for the specific language governing permissions and limitations18# under the License.19"""Test listing users.20"""21import datetime22import logging23from ceilometer.publisher import utils24from ceilometer import sample25from ceilometer.tests import api as tests_api26from ceilometer.tests import db as tests_db27LOG = logging.getLogger(__name__)28class TestListEmptyProjects(tests_api.TestBase,29 tests_db.MixinTestsWithBackendScenarios):30 def test_empty(self):31 data = self.get('/projects')32 self.assertEqual({'projects': []}, data)33class TestListProjects(tests_api.TestBase,34 tests_db.MixinTestsWithBackendScenarios):35 def setUp(self):36 super(TestListProjects, self).setUp()37 sample1 = sample.Sample(38 'instance',39 'cumulative',40 'instance',41 1,42 'user-id',43 'project-id',44 'resource-id',45 timestamp=datetime.datetime(2012, 7, 2, 10, 40),46 resource_metadata={'display_name': 'test-server',47 'tag': 'self.sample'},48 source='test_list_projects',49 )50 msg = utils.meter_message_from_counter(51 sample1,52 self.CONF.publisher.metering_secret,53 )54 self.conn.record_metering_data(msg)55 sample2 = sample.Sample(56 'instance',57 'cumulative',58 'instance',59 1,60 'user-id2',61 'project-id2',62 'resource-id-alternate',63 timestamp=datetime.datetime(2012, 7, 2, 10, 41),64 resource_metadata={'display_name': 'test-server',65 'tag': 'self.sample2'},66 source='test_list_users',67 )68 msg2 = utils.meter_message_from_counter(69 sample2,70 self.CONF.publisher.metering_secret,71 )72 self.conn.record_metering_data(msg2)73 def test_projects(self):74 data = self.get('/projects')75 self.assertEqual(['project-id', 'project-id2'], data['projects'])76 def test_projects_non_admin(self):77 data = self.get('/projects',78 headers={"X-Roles": "Member",79 "X-Project-Id": "project-id"})80 self.assertEqual(['project-id'], data['projects'])81 def test_with_source(self):82 data = self.get('/sources/test_list_users/projects')83 self.assertEqual(['project-id2'], data['projects'])84 def test_with_source_non_admin(self):85 data = self.get('/sources/test_list_users/projects',86 headers={"X-Roles": "Member",87 "X-Project-Id": "project-id2"})...

Full Screen

Full Screen

list_projects.py

Source:list_projects.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2#3# Copyright © 2012 New Dream Network, LLC (DreamHost)4#5# Author: Doug Hellmann <doug.hellmann@dreamhost.com>6# Julien Danjou <julien@danjou.info>7#8# Licensed under the Apache License, Version 2.0 (the "License"); you may9# not use this file except in compliance with the License. You may obtain10# a copy of the License at11#12# http://www.apache.org/licenses/LICENSE-2.013#14# Unless required by applicable law or agreed to in writing, software15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the17# License for the specific language governing permissions and limitations18# under the License.19"""Test listing users.20"""21import datetime22import logging23from oslo.config import cfg24from ceilometer.publisher import rpc25from ceilometer import counter26from ceilometer.tests import api as tests_api27LOG = logging.getLogger(__name__)28class TestListEmptyProjects(tests_api.TestBase):29 def test_empty(self):30 data = self.get('/projects')31 self.assertEquals({'projects': []}, data)32class TestListProjects(tests_api.TestBase):33 def setUp(self):34 super(TestListProjects, self).setUp()35 counter1 = counter.Counter(36 'instance',37 'cumulative',38 'instance',39 1,40 'user-id',41 'project-id',42 'resource-id',43 timestamp=datetime.datetime(2012, 7, 2, 10, 40),44 resource_metadata={'display_name': 'test-server',45 'tag': 'self.counter'}46 )47 msg = rpc.meter_message_from_counter(48 counter1,49 cfg.CONF.publisher_rpc.metering_secret,50 'test_list_projects',51 )52 self.conn.record_metering_data(msg)53 counter2 = counter.Counter(54 'instance',55 'cumulative',56 'instance',57 1,58 'user-id2',59 'project-id2',60 'resource-id-alternate',61 timestamp=datetime.datetime(2012, 7, 2, 10, 41),62 resource_metadata={'display_name': 'test-server',63 'tag': 'self.counter2'}64 )65 msg2 = rpc.meter_message_from_counter(66 counter2,67 cfg.CONF.publisher_rpc.metering_secret,68 'test_list_users',69 )70 self.conn.record_metering_data(msg2)71 def test_projects(self):72 data = self.get('/projects')73 self.assertEquals(['project-id', 'project-id2'], data['projects'])74 def test_projects_non_admin(self):75 data = self.get('/projects',76 headers={"X-Roles": "Member",77 "X-Tenant-Id": "project-id"})78 self.assertEquals(['project-id'], data['projects'])79 def test_with_source(self):80 data = self.get('/sources/test_list_users/projects')81 self.assertEquals(['project-id2'], data['projects'])82 def test_with_source_non_admin(self):83 data = self.get('/sources/test_list_users/projects',84 headers={"X-Roles": "Member",85 "X-Tenant-Id": "project-id2"})...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful