Пример #1
0
def needs_aws_s3(test_item):
    """Use as a decorator before test classes or methods to run only if AWS S3 is usable."""
    # TODO: we just check for generic access to the AWS account
    test_item = _mark_test('aws-s3', test_item)
    try:
        from boto import config
        boto_credentials = config.get('Credentials', 'aws_access_key_id')
    except ImportError:
        return unittest.skip(
            "Install Toil with the 'aws' extra to include this test.")(
                test_item)

    if not (boto_credentials or os.path.exists(
            os.path.expanduser('~/.aws/credentials')) or running_on_ec2()):
        return unittest.skip(
            "Configure AWS credentials to include this test.")(test_item)
    return test_item
Пример #2
0
 def awsRegion(cls):
     """
     Use us-west-2 unless running on EC2, in which case use the region in which
     the instance is located
     """
     return cls._region() if running_on_ec2() else 'us-west-2'