Example #1
0
def with_cleanup(aws_creds, request):

    # tear-down: clean up all specially-marked HITs:
    def test_hits_only(hit):
        return TEST_HIT_DESCRIPTION in hit["description"]
        return hit["description"] == TEST_HIT_DESCRIPTION + system_marker()

    params = {"region_name": "us-east-1"}
    params.update(aws_creds)
    service = MTurkService(**params)

    # In tests we do a lot of querying of Qualifications we only just created,
    # so we need a long time-out
    service.max_wait_secs = 60.0
    try:
        yield service
    except Exception as e:
        raise e
    finally:
        try:
            for hit in service.get_hits(test_hits_only):
                service.disable_hit(hit["id"])
        except Exception:
            # Broad exception so we don't leak credentials in Travis CI logs
            pass
Example #2
0
def with_cleanup(aws_creds, request):

    # tear-down: clean up all specially-marked HITs:
    def test_hits_only(hit):
        return hit['description'] == TEST_HIT_DESCRIPTION + str(os.getpid())

    service = MTurkService(**aws_creds)
    # In tests we do a lot of querying of Qualifications we only just created,
    # so we need a long time-out
    service.max_wait_secs = 60.0
    try:
        yield service
    except Exception as e:
        raise e
    finally:
        try:
            for hit in service.get_hits(test_hits_only):
                service.disable_hit(hit['id'])
        except Exception:
            # Broad exception so we don't leak credentials in Travis CI logs
            pass