def test_create(self): fake_share_group = fake.ShareGroup() mock_create = self.mock_object( self.manager, '_create', mock.Mock(return_value=fake_share_group)) create_args = { 'name': fake.ShareGroup.name, 'description': fake.ShareGroup.description, 'availability_zone': fake.ShareGroup.availability_zone, 'share_group_type': fake.ShareGroupType(), 'share_types': [fake.ShareType()], 'share_network': fake.ShareNetwork(), } result = self.manager.create(**create_args) self.assertIs(fake_share_group, result) expected_body = { share_groups.RESOURCE_NAME: { 'name': fake.ShareGroup.name, 'description': fake.ShareGroup.description, 'share_group_type_id': fake.ShareGroupType().id, 'share_network_id': fake.ShareNetwork().id, 'share_types': [fake.ShareType().id], 'availability_zone': fake.ShareGroup.availability_zone, }, } mock_create.assert_called_once_with(share_groups.RESOURCES_PATH, expected_body, share_groups.RESOURCE_NAME)
def test_create(self): fake_share_group_type = fake.ShareGroupType() mock_create = self.mock_object( self.manager, '_create', mock.Mock(return_value=fake_share_group_type)) create_args = { 'name': fake.ShareGroupType.name, 'share_types': [fake.ShareType()], 'is_public': False, 'group_specs': self.fake_group_specs, } result = self.manager.create(**create_args) self.assertIs(fake_share_group_type, result) expected_body = { types.RESOURCE_NAME: { 'name': fake.ShareGroupType.name, 'share_types': [fake.ShareType().id], 'is_public': False, 'group_specs': self.fake_group_specs, }, } mock_create.assert_called_once_with(types.RESOURCES_PATH, expected_body, types.RESOURCE_NAME)
def test_create_invalid_arguments(self): create_args = { 'name': fake.ShareGroup.name, 'description': fake.ShareGroup.description, 'share_types': [fake.ShareType().id], 'source_share_group_snapshot': fake.ShareGroupSnapshot(), } self.assertRaises(ValueError, self.manager.create, **create_args)