<s> from novaclient import exceptions <EOL> from novaclient . tests . unit . fixture_data import client <EOL> from novaclient . tests . unit . fixture_data import server_groups as data <EOL> from novaclient . tests . unit import utils <EOL> from novaclient . tests . unit . v2 import fakes <EOL> from novaclient . v2 import server_groups <EOL> class ServerGroupsTest ( utils . FixturedTestCase ) : <EOL> client_fixture_class = client . V1 <EOL> data_fixture_class = data . Fixture <EOL> def test_list_server_groups ( self ) : <EOL> result = self . cs . server_groups . list ( ) <EOL> self . assert_request_id ( result , fakes . FAKE_REQUEST_ID_LIST ) <EOL> self . assert_called ( '<STR_LIT:GET>' , '<STR_LIT>' ) <EOL> for server_group in result : <EOL> self . assertIsInstance ( server_group , <EOL> server_groups . ServerGroup ) <EOL> def test_list_server_groups_with_all_projects ( self ) : <EOL> result = self . cs . server_groups . list ( all_projects = True ) <EOL> self . assert_request_id ( result , fakes . FAKE_REQUEST_ID_LIST ) <EOL> self . assert_called ( '<STR_LIT:GET>' , '<STR_LIT>' ) <EOL> for server_group in result : <EOL> self . assertIsInstance ( server_group , <EOL> server_groups . ServerGroup ) <EOL> def test_create_server_group ( self ) : <EOL> kwargs = { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] } <EOL> server_group = self . cs . server_groups . create ( ** kwargs ) <EOL> self . assert_request_id ( server_group , fakes . FAKE_REQUEST_ID_LIST ) <EOL> body = { '<STR_LIT>' : kwargs } <EOL> self . assert_called ( '<STR_LIT:POST>' , '<STR_LIT>' , body ) <EOL> self . assertIsInstance ( server_group , <EOL> server_groups . ServerGroup ) <EOL> def test_get_server_group ( self ) : <EOL> id = '<STR_LIT>' <EOL> server_group = self . cs . server_groups . get ( id ) <EOL> self . assert_request_id ( server_group , fakes . FAKE_REQUEST_ID_LIST ) <EOL> self . assert_called ( '<STR_LIT:GET>' , '<STR_LIT>' % id ) <EOL> self . assertIsInstance ( server_group , <EOL> server_groups . ServerGroup ) <EOL> def test_delete_server_group ( self ) : <EOL> id = '<STR_LIT>' <EOL> ret = self . cs . server_groups . delete ( id ) <EOL> self . assert_request_id ( ret , fakes . FAKE_REQUEST_ID_LIST ) <EOL> self . assert_called ( '<STR_LIT>' , '<STR_LIT>' % id ) <EOL> def test_delete_server_group_object ( self ) : <EOL> id = '<STR_LIT>' <EOL> server_group = self . cs . server_groups . get ( id ) <EOL> ret = server_group . delete ( ) <EOL> self . assert_request_id ( ret , fakes . FAKE_REQUEST_ID_LIST ) <EOL> self . assert_called ( '<STR_LIT>' , '<STR_LIT>' % id ) <EOL> def test_find_server_groups_by_name ( self ) : <EOL> expected_name = '<STR_LIT>' <EOL> kwargs = { self . cs . server_groups . resource_class . NAME_ATTR : <EOL> expected_name } <EOL> server_group = self . cs . server_groups . find ( ** kwargs ) <EOL> self . assert_request_id ( server_group , fakes . FAKE_REQUEST_ID_LIST ) <EOL> self . assert_called ( '<STR_LIT:GET>' , '<STR_LIT>' ) <EOL> self . assertIsInstance ( server_group , server_groups . ServerGroup ) <EOL> actual_name = getattr ( server_group , <EOL> self . cs . server_groups . resource_class . NAME_ATTR ) <EOL> self . assertEqual ( expected_name , actual_name ) <EOL> def test_find_no_existing_server_groups_by_name ( self ) : <EOL> expected_name = '<STR_LIT>' <EOL> kwargs = { self . cs . server_groups . resource_class . NAME_ATTR : <EOL> expected_name } <EOL> self . assertRaises ( exceptions . NotFound , <EOL> self . cs . server_groups . find , <EOL> ** kwargs ) <EOL> self . assert_called ( '<STR_LIT:GET>' , '<STR_LIT>' ) </s>
