desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Test grant revoke in mysql exec module'
| @skipIf(True, 'TODO: Mock up user_grants()')
def test_grant_revoke(self):
| self._test_call(mysql.grant_revoke, '', 'SELECT,INSERT,UPDATE', 'database.*', 'frank', 'localhost')
|
'Test processlist function in mysql exec module'
| def test_processlist(self):
| self._test_call(mysql.processlist, 'SHOW FULL PROCESSLIST')
|
'Test get_master_status in the mysql execution module'
| def test_get_master_status(self):
| self._test_call(mysql.get_master_status, 'SHOW MASTER STATUS')
|
'Test get_slave_status in the mysql execution module'
| def test_get_slave_status(self):
| self._test_call(mysql.get_slave_status, 'SHOW SLAVE STATUS')
|
'Test get_slave_status in the mysql execution module, simulating a broken server'
| def test_get_slave_status_bad_server(self):
| connect_mock = MagicMock(return_value=None)
with patch.object(mysql, '_connect', connect_mock):
with patch.dict(mysql.__salt__, {'config.option': MagicMock()}):
rslt = mysql.get_slave_status()
connect_mock.assert_has_calls([call()])
self.assertEqual(rslt, [])
|
'Test writing a default setting'
| def test_write_default(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run_all': mock}):
macdefaults.write('com.apple.CrashReporter', 'DialogType', 'Server')
mock.assert_called_once_with('defaults write "com.apple.CrashReporter" "DialogType" -string "Server"', runas=None)
|
'Test writing a default setting with a specific user'
| def test_write_with_user(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run_all': mock}):
macdefaults.write('com.apple.CrashReporter', 'DialogType', 'Server', user='frank')
mock.assert_called_once_with('defaults write "com.apple.CrashReporter" "DialogType" -string "Server"', runas='frank')
|
'Test writing a default setting'
| def test_write_default_boolean(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run_all': mock}):
macdefaults.write('com.apple.CrashReporter', 'Crash', True, type='boolean')
mock.assert_called_once_with('defaults write "com.apple.CrashReporter" "Crash" -boolean "TRUE"', runas=None)
|
'Test reading a default setting'
| def test_read_default(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run': mock}):
macdefaults.read('com.apple.CrashReporter', 'Crash')
mock.assert_called_once_with('defaults read "com.apple.CrashReporter" "Crash"', runas=None)
|
'Test reading a default setting as a specific user'
| def test_read_default_with_user(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run': mock}):
macdefaults.read('com.apple.CrashReporter', 'Crash', user='frank')
mock.assert_called_once_with('defaults read "com.apple.CrashReporter" "Crash"', runas='frank')
|
'Test delete a default setting'
| def test_delete_default(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run_all': mock}):
macdefaults.delete('com.apple.CrashReporter', 'Crash')
mock.assert_called_once_with('defaults delete "com.apple.CrashReporter" "Crash"', output_loglevel='debug', runas=None)
|
'Test delete a default setting as a specific user'
| def test_delete_default_with_user(self):
| mock = MagicMock()
with patch.dict(macdefaults.__salt__, {'cmd.run_all': mock}):
macdefaults.delete('com.apple.CrashReporter', 'Crash', user='frank')
mock.assert_called_once_with('defaults delete "com.apple.CrashReporter" "Crash"', output_loglevel='debug', runas='frank')
|
'Tests checking cloudtrail trail existence when the cloudtrail trail already exists'
| def test_that_when_checking_if_a_trail_exists_and_a_trail_exists_the_trail_exists_method_returns_true(self):
| self.conn.get_trail_status.return_value = trail_ret
result = boto_cloudtrail.exists(Name=trail_ret['Name'], **conn_parameters)
self.assertTrue(result['exists'])
|
'Tests checking cloudtrail trail existence when the cloudtrail trail does not exist'
| def test_that_when_checking_if_a_trail_exists_and_a_trail_does_not_exist_the_trail_exists_method_returns_false(self):
| self.conn.get_trail_status.side_effect = not_found_error
result = boto_cloudtrail.exists(Name='mytrail', **conn_parameters)
self.assertFalse(result['exists'])
|
'Tests checking cloudtrail trail existence when boto returns an error'
| def test_that_when_checking_if_a_trail_exists_and_boto3_returns_an_error_the_trail_exists_method_returns_error(self):
| self.conn.get_trail_status.side_effect = ClientError(error_content, 'get_trail_status')
result = boto_cloudtrail.exists(Name='mytrail', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('get_trail_status'))
|
'tests True trail created.'
| def test_that_when_creating_a_trail_succeeds_the_create_trail_method_returns_true(self):
| self.conn.create_trail.return_value = trail_ret
result = boto_cloudtrail.create(Name=trail_ret['Name'], S3BucketName=trail_ret['S3BucketName'], **conn_parameters)
self.assertTrue(result['created'])
|
'tests False trail not created.'
| def test_that_when_creating_a_trail_fails_the_create_trail_method_returns_error(self):
| self.conn.create_trail.side_effect = ClientError(error_content, 'create_trail')
result = boto_cloudtrail.create(Name=trail_ret['Name'], S3BucketName=trail_ret['S3BucketName'], **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('create_trail'))
|
'tests True trail deleted.'
| def test_that_when_deleting_a_trail_succeeds_the_delete_trail_method_returns_true(self):
| result = boto_cloudtrail.delete(Name='testtrail', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False trail not deleted.'
| def test_that_when_deleting_a_trail_fails_the_delete_trail_method_returns_false(self):
| self.conn.delete_trail.side_effect = ClientError(error_content, 'delete_trail')
result = boto_cloudtrail.delete(Name='testtrail', **conn_parameters)
self.assertFalse(result['deleted'])
|
'Tests describing parameters if trail exists'
| def test_that_when_describing_trail_it_returns_the_dict_of_properties_returns_true(self):
| self.conn.describe_trails.return_value = {'trailList': [trail_ret]}
result = boto_cloudtrail.describe(Name=trail_ret['Name'], **conn_parameters)
self.assertTrue(result['trail'])
|
'Tests describing parameters if trail does not exist'
| def test_that_when_describing_trail_it_returns_the_dict_of_properties_returns_false(self):
| self.conn.describe_trails.side_effect = not_found_error
result = boto_cloudtrail.describe(Name='testtrail', **conn_parameters)
self.assertFalse(result['trail'])
|
'Tests describing parameters failure'
| def test_that_when_describing_trail_on_client_error_it_returns_error(self):
| self.conn.describe_trails.side_effect = ClientError(error_content, 'get_trail')
result = boto_cloudtrail.describe(Name='testtrail', **conn_parameters)
self.assertTrue(('error' in result))
|
'Tests getting status if trail exists'
| def test_that_when_getting_status_it_returns_the_dict_of_properties_returns_true(self):
| self.conn.get_trail_status.return_value = status_ret
result = boto_cloudtrail.status(Name=trail_ret['Name'], **conn_parameters)
self.assertTrue(result['trail'])
|
'Tests getting status if trail does not exist'
| def test_that_when_getting_status_it_returns_the_dict_of_properties_returns_false(self):
| self.conn.get_trail_status.side_effect = not_found_error
result = boto_cloudtrail.status(Name='testtrail', **conn_parameters)
self.assertFalse(result['trail'])
|
'Tests getting status failure'
| def test_that_when_getting_status_on_client_error_it_returns_error(self):
| self.conn.get_trail_status.side_effect = ClientError(error_content, 'get_trail_status')
result = boto_cloudtrail.status(Name='testtrail', **conn_parameters)
self.assertTrue(('error' in result))
|
'tests True trails listed.'
| def test_that_when_listing_trails_succeeds_the_list_trails_method_returns_true(self):
| self.conn.describe_trails.return_value = {'trailList': [trail_ret]}
result = boto_cloudtrail.list(**conn_parameters)
self.assertTrue(result['trails'])
|
'tests False no trail listed.'
| def test_that_when_listing_trail_fails_the_list_trail_method_returns_false(self):
| self.conn.describe_trails.return_value = {'trailList': []}
result = boto_cloudtrail.list(**conn_parameters)
self.assertFalse(result['trails'])
|
'tests False trail error.'
| def test_that_when_listing_trail_fails_the_list_trail_method_returns_error(self):
| self.conn.describe_trails.side_effect = ClientError(error_content, 'list_trails')
result = boto_cloudtrail.list(**conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('list_trails'))
|
'tests True trail updated.'
| def test_that_when_updating_a_trail_succeeds_the_update_trail_method_returns_true(self):
| self.conn.update_trail.return_value = trail_ret
result = boto_cloudtrail.update(Name=trail_ret['Name'], S3BucketName=trail_ret['S3BucketName'], **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False trail not updated.'
| def test_that_when_updating_a_trail_fails_the_update_trail_method_returns_error(self):
| self.conn.update_trail.side_effect = ClientError(error_content, 'update_trail')
result = boto_cloudtrail.update(Name=trail_ret['Name'], S3BucketName=trail_ret['S3BucketName'], **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('update_trail'))
|
'tests True logging started.'
| def test_that_when_starting_logging_succeeds_the_start_logging_method_returns_true(self):
| result = boto_cloudtrail.start_logging(Name=trail_ret['Name'], **conn_parameters)
self.assertTrue(result['started'])
|
'tests False logging not started.'
| def test_that_when_start_logging_fails_the_start_logging_method_returns_false(self):
| self.conn.describe_trails.return_value = {'trailList': []}
self.conn.start_logging.side_effect = ClientError(error_content, 'start_logging')
result = boto_cloudtrail.start_logging(Name=trail_ret['Name'], **conn_parameters)
self.assertFalse(result['started'])
|
'tests True logging stopped.'
| def test_that_when_stopping_logging_succeeds_the_stop_logging_method_returns_true(self):
| result = boto_cloudtrail.stop_logging(Name=trail_ret['Name'], **conn_parameters)
self.assertTrue(result['stopped'])
|
'tests False logging not stopped.'
| def test_that_when_stop_logging_fails_the_stop_logging_method_returns_false(self):
| self.conn.describe_trails.return_value = {'trailList': []}
self.conn.stop_logging.side_effect = ClientError(error_content, 'stop_logging')
result = boto_cloudtrail.stop_logging(Name=trail_ret['Name'], **conn_parameters)
self.assertFalse(result['stopped'])
|
'tests True tags added.'
| def test_that_when_adding_tags_succeeds_the_add_tags_method_returns_true(self):
| with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
result = boto_cloudtrail.add_tags(Name=trail_ret['Name'], a='b', **conn_parameters)
self.assertTrue(result['tagged'])
|
'tests False tags not added.'
| def test_that_when_adding_tags_fails_the_add_tags_method_returns_false(self):
| self.conn.add_tags.side_effect = ClientError(error_content, 'add_tags')
with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
result = boto_cloudtrail.add_tags(Name=trail_ret['Name'], a='b', **conn_parameters)
self.assertFalse(result['tagged'])
|
'tests True tags removed.'
| def test_that_when_removing_tags_succeeds_the_remove_tags_method_returns_true(self):
| with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
result = boto_cloudtrail.remove_tags(Name=trail_ret['Name'], a='b', **conn_parameters)
self.assertTrue(result['tagged'])
|
'tests False tags not removed.'
| def test_that_when_removing_tags_fails_the_remove_tags_method_returns_false(self):
| self.conn.remove_tags.side_effect = ClientError(error_content, 'remove_tags')
with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
result = boto_cloudtrail.remove_tags(Name=trail_ret['Name'], a='b', **conn_parameters)
self.assertFalse(result['tagged'])
|
'tests True tags listed.'
| def test_that_when_listing_tags_succeeds_the_list_tags_method_returns_true(self):
| with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
result = boto_cloudtrail.list_tags(Name=trail_ret['Name'], **conn_parameters)
self.assertEqual(result['tags'], {})
|
'tests False tags not listed.'
| def test_that_when_listing_tags_fails_the_list_tags_method_returns_false(self):
| self.conn.list_tags.side_effect = ClientError(error_content, 'list_tags')
with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
result = boto_cloudtrail.list_tags(Name=trail_ret['Name'], **conn_parameters)
self.assertTrue(result['error'])
|
'Tests checking s3 bucket existence when the s3 bucket already exists'
| def test_that_when_checking_if_a_bucket_exists_and_a_bucket_exists_the_bucket_exists_method_returns_true(self):
| self.conn.head_bucket.return_value = None
result = boto_s3_bucket.exists(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['exists'])
|
'Tests checking s3 bucket existence when the s3 bucket does not exist'
| def test_that_when_checking_if_a_bucket_exists_and_a_bucket_does_not_exist_the_bucket_exists_method_returns_false(self):
| self.conn.head_bucket.side_effect = e404_error
result = boto_s3_bucket.exists(Bucket='mybucket', **conn_parameters)
self.assertFalse(result['exists'])
|
'Tests checking s3 bucket existence when boto returns an error'
| def test_that_when_checking_if_a_bucket_exists_and_boto3_returns_an_error_the_bucket_exists_method_returns_error(self):
| self.conn.head_bucket.side_effect = ClientError(error_content, 'head_bucket')
result = boto_s3_bucket.exists(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('head_bucket'))
|
'tests True bucket created.'
| def test_that_when_creating_a_bucket_succeeds_the_create_bucket_method_returns_true(self):
| self.conn.create_bucket.return_value = create_ret
result = boto_s3_bucket.create(Bucket='mybucket', LocationConstraint='nowhere', **conn_parameters)
self.assertTrue(result['created'])
|
'tests False bucket not created.'
| def test_that_when_creating_a_bucket_fails_the_create_bucket_method_returns_error(self):
| self.conn.create_bucket.side_effect = ClientError(error_content, 'create_bucket')
result = boto_s3_bucket.create(Bucket='mybucket', LocationConstraint='nowhere', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('create_bucket'))
|
'tests True bucket deleted.'
| def test_that_when_deleting_a_bucket_succeeds_the_delete_bucket_method_returns_true(self):
| result = boto_s3_bucket.delete(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket not deleted.'
| def test_that_when_deleting_a_bucket_fails_the_delete_bucket_method_returns_false(self):
| self.conn.delete_bucket.side_effect = ClientError(error_content, 'delete_bucket')
result = boto_s3_bucket.delete(Bucket='mybucket', **conn_parameters)
self.assertFalse(result['deleted'])
|
'Tests describing parameters if bucket exists'
| def test_that_when_describing_bucket_it_returns_the_dict_of_properties_returns_true(self):
| for (key, value) in six.iteritems(config_ret):
getattr(self.conn, key).return_value = deepcopy(value)
result = boto_s3_bucket.describe(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['bucket'])
|
'Tests describing parameters if bucket does not exist'
| def test_that_when_describing_bucket_it_returns_the_dict_of_properties_returns_false(self):
| self.conn.get_bucket_acl.side_effect = not_found_error
result = boto_s3_bucket.describe(Bucket='mybucket', **conn_parameters)
self.assertFalse(result['bucket'])
|
'Tests describing parameters failure'
| def test_that_when_describing_bucket_on_client_error_it_returns_error(self):
| self.conn.get_bucket_acl.side_effect = ClientError(error_content, 'get_bucket_acl')
result = boto_s3_bucket.describe(Bucket='mybucket', **conn_parameters)
self.assertTrue(('error' in result))
|
'tests True buckets listed.'
| def test_that_when_listing_buckets_succeeds_the_list_buckets_method_returns_true(self):
| self.conn.list_buckets.return_value = deepcopy(list_ret)
result = boto_s3_bucket.list(**conn_parameters)
self.assertTrue(result['Buckets'])
|
'tests False no bucket listed.'
| def test_that_when_listing_bucket_fails_the_list_bucket_method_returns_false(self):
| ret = deepcopy(list_ret)
log.info(ret)
ret['Buckets'] = list()
self.conn.list_buckets.return_value = ret
result = boto_s3_bucket.list(**conn_parameters)
self.assertFalse(result['Buckets'])
|
'tests False bucket error.'
| def test_that_when_listing_bucket_fails_the_list_bucket_method_returns_error(self):
| self.conn.list_buckets.side_effect = ClientError(error_content, 'list_buckets')
result = boto_s3_bucket.list(**conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('list_buckets'))
|
'tests True bucket updated.'
| def test_that_when_putting_acl_succeeds_the_put_acl_method_returns_true(self):
| result = boto_s3_bucket.put_acl(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_acl_fails_the_put_acl_method_returns_error(self):
| self.conn.put_bucket_acl.side_effect = ClientError(error_content, 'put_bucket_acl')
result = boto_s3_bucket.put_acl(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_acl'))
|
'tests True bucket updated.'
| def test_that_when_putting_cors_succeeds_the_put_cors_method_returns_true(self):
| result = boto_s3_bucket.put_cors(Bucket='mybucket', CORSRules='[]', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_cors_fails_the_put_cors_method_returns_error(self):
| self.conn.put_bucket_cors.side_effect = ClientError(error_content, 'put_bucket_cors')
result = boto_s3_bucket.put_cors(Bucket='mybucket', CORSRules='[]', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_cors'))
|
'tests True bucket updated.'
| def test_that_when_putting_lifecycle_configuration_succeeds_the_put_lifecycle_configuration_method_returns_true(self):
| result = boto_s3_bucket.put_lifecycle_configuration(Bucket='mybucket', Rules='[]', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_lifecycle_configuration_fails_the_put_lifecycle_configuration_method_returns_error(self):
| self.conn.put_bucket_lifecycle_configuration.side_effect = ClientError(error_content, 'put_bucket_lifecycle_configuration')
result = boto_s3_bucket.put_lifecycle_configuration(Bucket='mybucket', Rules='[]', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_lifecycle_configuration'))
|
'tests True bucket updated.'
| def test_that_when_putting_logging_succeeds_the_put_logging_method_returns_true(self):
| result = boto_s3_bucket.put_logging(Bucket='mybucket', TargetBucket='arn:::::', TargetPrefix='asdf', TargetGrants='[]', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_logging_fails_the_put_logging_method_returns_error(self):
| self.conn.put_bucket_logging.side_effect = ClientError(error_content, 'put_bucket_logging')
result = boto_s3_bucket.put_logging(Bucket='mybucket', TargetBucket='arn:::::', TargetPrefix='asdf', TargetGrants='[]', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_logging'))
|
'tests True bucket updated.'
| def test_that_when_putting_notification_configuration_succeeds_the_put_notification_configuration_method_returns_true(self):
| result = boto_s3_bucket.put_notification_configuration(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_notification_configuration_fails_the_put_notification_configuration_method_returns_error(self):
| self.conn.put_bucket_notification_configuration.side_effect = ClientError(error_content, 'put_bucket_notification_configuration')
result = boto_s3_bucket.put_notification_configuration(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_notification_configuration'))
|
'tests True bucket updated.'
| def test_that_when_putting_policy_succeeds_the_put_policy_method_returns_true(self):
| result = boto_s3_bucket.put_policy(Bucket='mybucket', Policy='{}', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_policy_fails_the_put_policy_method_returns_error(self):
| self.conn.put_bucket_policy.side_effect = ClientError(error_content, 'put_bucket_policy')
result = boto_s3_bucket.put_policy(Bucket='mybucket', Policy='{}', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_policy'))
|
'tests True bucket updated.'
| def test_that_when_putting_replication_succeeds_the_put_replication_method_returns_true(self):
| result = boto_s3_bucket.put_replication(Bucket='mybucket', Role='arn:aws:iam:::', Rules='[]', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_replication_fails_the_put_replication_method_returns_error(self):
| self.conn.put_bucket_replication.side_effect = ClientError(error_content, 'put_bucket_replication')
result = boto_s3_bucket.put_replication(Bucket='mybucket', Role='arn:aws:iam:::', Rules='[]', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_replication'))
|
'tests True bucket updated.'
| def test_that_when_putting_request_payment_succeeds_the_put_request_payment_method_returns_true(self):
| result = boto_s3_bucket.put_request_payment(Bucket='mybucket', Payer='Requester', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_request_payment_fails_the_put_request_payment_method_returns_error(self):
| self.conn.put_bucket_request_payment.side_effect = ClientError(error_content, 'put_bucket_request_payment')
result = boto_s3_bucket.put_request_payment(Bucket='mybucket', Payer='Requester', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_request_payment'))
|
'tests True bucket updated.'
| def test_that_when_putting_tagging_succeeds_the_put_tagging_method_returns_true(self):
| result = boto_s3_bucket.put_tagging(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_tagging_fails_the_put_tagging_method_returns_error(self):
| self.conn.put_bucket_tagging.side_effect = ClientError(error_content, 'put_bucket_tagging')
result = boto_s3_bucket.put_tagging(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_tagging'))
|
'tests True bucket updated.'
| def test_that_when_putting_versioning_succeeds_the_put_versioning_method_returns_true(self):
| result = boto_s3_bucket.put_versioning(Bucket='mybucket', Status='Enabled', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_versioning_fails_the_put_versioning_method_returns_error(self):
| self.conn.put_bucket_versioning.side_effect = ClientError(error_content, 'put_bucket_versioning')
result = boto_s3_bucket.put_versioning(Bucket='mybucket', Status='Enabled', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_versioning'))
|
'tests True bucket updated.'
| def test_that_when_putting_website_succeeds_the_put_website_method_returns_true(self):
| result = boto_s3_bucket.put_website(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['updated'])
|
'tests False bucket not updated.'
| def test_that_when_putting_website_fails_the_put_website_method_returns_error(self):
| self.conn.put_bucket_website.side_effect = ClientError(error_content, 'put_bucket_website')
result = boto_s3_bucket.put_website(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('put_bucket_website'))
|
'tests True bucket attribute deleted.'
| def test_that_when_deleting_cors_succeeds_the_delete_cors_method_returns_true(self):
| result = boto_s3_bucket.delete_cors(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket attribute not deleted.'
| def test_that_when_deleting_cors_fails_the_delete_cors_method_returns_error(self):
| self.conn.delete_bucket_cors.side_effect = ClientError(error_content, 'delete_bucket_cors')
result = boto_s3_bucket.delete_cors(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_cors'))
|
'tests True bucket attribute deleted.'
| def test_that_when_deleting_lifecycle_configuration_succeeds_the_delete_lifecycle_configuration_method_returns_true(self):
| result = boto_s3_bucket.delete_lifecycle_configuration(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket attribute not deleted.'
| def test_that_when_deleting_lifecycle_configuration_fails_the_delete_lifecycle_configuration_method_returns_error(self):
| self.conn.delete_bucket_lifecycle.side_effect = ClientError(error_content, 'delete_bucket_lifecycle_configuration')
result = boto_s3_bucket.delete_lifecycle_configuration(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_lifecycle_configuration'))
|
'tests True bucket attribute deleted.'
| def test_that_when_deleting_policy_succeeds_the_delete_policy_method_returns_true(self):
| result = boto_s3_bucket.delete_policy(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket attribute not deleted.'
| def test_that_when_deleting_policy_fails_the_delete_policy_method_returns_error(self):
| self.conn.delete_bucket_policy.side_effect = ClientError(error_content, 'delete_bucket_policy')
result = boto_s3_bucket.delete_policy(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_policy'))
|
'tests True bucket attribute deleted.'
| def test_that_when_deleting_replication_succeeds_the_delete_replication_method_returns_true(self):
| result = boto_s3_bucket.delete_replication(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket attribute not deleted.'
| def test_that_when_deleting_replication_fails_the_delete_replication_method_returns_error(self):
| self.conn.delete_bucket_replication.side_effect = ClientError(error_content, 'delete_bucket_replication')
result = boto_s3_bucket.delete_replication(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_replication'))
|
'tests True bucket attribute deleted.'
| def test_that_when_deleting_tagging_succeeds_the_delete_tagging_method_returns_true(self):
| result = boto_s3_bucket.delete_tagging(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket attribute not deleted.'
| def test_that_when_deleting_tagging_fails_the_delete_tagging_method_returns_error(self):
| self.conn.delete_bucket_tagging.side_effect = ClientError(error_content, 'delete_bucket_tagging')
result = boto_s3_bucket.delete_tagging(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_tagging'))
|
'tests True bucket attribute deleted.'
| def test_that_when_deleting_website_succeeds_the_delete_website_method_returns_true(self):
| result = boto_s3_bucket.delete_website(Bucket='mybucket', **conn_parameters)
self.assertTrue(result['deleted'])
|
'tests False bucket attribute not deleted.'
| def test_that_when_deleting_website_fails_the_delete_website_method_returns_error(self):
| self.conn.delete_bucket_website.side_effect = ClientError(error_content, 'delete_bucket_website')
result = boto_s3_bucket.delete_website(Bucket='mybucket', **conn_parameters)
self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_website'))
|
'Test for start Riak'
| def test_start(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(riak.start(), {'success': True, 'comment': 'success'})
|
'Test for stop Riak'
| def test_stop(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(riak.stop(), {'success': True, 'comment': 'success'})
|
'Test for Join a Riak cluster'
| def test_cluster_join(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(riak.cluster_join('A', 'B'), {'success': True, 'comment': 'success'})
|
'Test for leaving a Riak cluster'
| def test_cluster_leave(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(riak.cluster_leave('A', 'B'), {'success': True, 'comment': 'success'})
|
'Test for Review Cluster Plan'
| def test_cluster_plan(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertTrue(riak.cluster_plan())
|
'Test for Commit Cluster Changes'
| def test_cluster_commit(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(riak.cluster_commit(), {'success': True, 'comment': 'success'})
|
'Test for Get cluster member status'
| def test_member_status(self):
| with patch.object(riak, '__execute_cmd', return_value={'stdout': 'A:a/B:b\nC:c/D:d'}):
self.assertDictEqual(riak.member_status(), {'membership': {}, 'summary': {'A': 'a', 'C': 'c', 'B': 'b', 'D': 'd', 'Exiting': 0, 'Down': 0, 'Valid': 0, 'Leaving': 0, 'Joining': 0}})
|
'Test status information'
| def test_status(self):
| ret = {'stdout': 'vnode_map_update_time_95 : 0\nvnode_map_update_time_99 : 0'}
with patch.object(riak, '__execute_cmd', return_value=ret):
self.assertEqual(riak.status(), {'vnode_map_update_time_95': '0', 'vnode_map_update_time_99': '0'})
|
'Test the Riak test'
| def test_test(self):
| with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(riak.test(), {'success': True, 'comment': 'success'})
|
'Test Riak Service List'
| def test_services(self):
| with patch.object(riak, '__execute_cmd', return_value={'stdout': '[a,b,c]'}):
self.assertEqual(riak.services(), ['a', 'b', 'c'])
|
'Tests the return of get function'
| def test_get(self):
| mock_cmd = MagicMock(return_value=1)
with patch.dict(linux_sysctl.__salt__, {'cmd.run': mock_cmd}):
self.assertEqual(linux_sysctl.get('net.ipv4.ip_forward'), 1)
|
'Tests if /proc/sys/<kernel-subsystem> exists or not'
| def test_assign_proc_sys_failed(self):
| with patch('os.path.exists', MagicMock(return_value=False)):
cmd = {'pid': 1337, 'retcode': 0, 'stderr': '', 'stdout': 'net.ipv4.ip_forward = 1'}
mock_cmd = MagicMock(return_value=cmd)
with patch.dict(linux_sysctl.__salt__, {'cmd.run_all': mock_cmd}):
self.assertRaises(CommandExecutionError, linux_sysctl.assign, 'net.ipv4.ip_forward', 1)
|
'Tests if the assignment was successful or not'
| def test_assign_cmd_failed(self):
| with patch('os.path.exists', MagicMock(return_value=True)):
cmd = {'pid': 1337, 'retcode': 0, 'stderr': 'sysctl: setting key "net.ipv4.ip_forward": Invalid argument', 'stdout': 'net.ipv4.ip_forward = backward'}
mock_cmd = MagicMock(return_value=cmd)
with patch.dict(linux_sysctl.__salt__, {'cmd.run_all': mock_cmd}):
self.assertRaises(CommandExecutionError, linux_sysctl.assign, 'net.ipv4.ip_forward', 'backward')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.