Пример #1
0
 def test_open_recruitment_with_blocklist(self, recruiter):
     recruiter.config.set("mturk_qualification_blocklist", u"foo, bar")
     # Our fake response will always return the same QualificationType ID
     recruiter.mturkservice.get_qualification_type_by_name.return_value = {
         "id": u"fake id"
     }
     recruiter.open_recruitment(n=1)
     recruiter.mturkservice.create_hit.assert_called_once_with(
         question=MTurkQuestions.external(
             ad_url="http://fake-domain/ad?recruiter=mturk"),
         description="fake HIT description",
         duration_hours=1.0,
         experiment_id="TEST_EXPERIMENT_UID",
         lifetime_days=1,
         keywords=[u"kw1", u"kw2", u"kw3"],
         max_assignments=1,
         notification_url="http://fake-domain{}".format(SNS_ROUTE_PATH),
         reward=0.01,
         title="fake experiment title",
         annotation="TEST_EXPERIMENT_UID",
         qualifications=[
             MTurkQualificationRequirements.min_approval(95),
             MTurkQualificationRequirements.restrict_to_countries(["US"]),
             MTurkQualificationRequirements.must_not_have(u"fake id"),
             MTurkQualificationRequirements.must_not_have(u"fake id"),
         ],
     )
Пример #2
0
 def test_open_recruitment_single_recruitee_builds_hit(self, recruiter):
     recruiter.open_recruitment(n=1)
     recruiter.mturkservice.create_hit.assert_called_once_with(
         question=MTurkQuestions.external(
             ad_url="http://fake-domain/ad?recruiter=mturk"),
         description=u"fake HIT description",
         duration_hours=1.0,
         experiment_id="TEST_EXPERIMENT_UID",
         keywords=[u"kw1", u"kw2", u"kw3"],
         lifetime_days=1,
         max_assignments=1,
         notification_url=u"http://fake-domain{}".format(SNS_ROUTE_PATH),
         reward=0.01,
         title=u"fake experiment title",
         annotation="TEST_EXPERIMENT_UID",
         qualifications=[
             MTurkQualificationRequirements.min_approval(95),
             MTurkQualificationRequirements.restrict_to_countries(["US"]),
         ],
     )
Пример #3
0
 def test_open_recruitment_with_more_than_pool_size_uses_requested_count(
         self, recruiter):
     num_recruits = recruiter.pool_size + 1
     recruiter.open_recruitment(n=num_recruits)
     recruiter.mturkservice.create_hit.assert_called_once_with(
         question=MTurkQuestions.external(
             ad_url="http://fake-domain/ad?recruiter=mturklarge"),
         description="fake HIT description",
         duration_hours=1.0,
         experiment_id="TEST_EXPERIMENT_UID",
         keywords=["kw1", "kw2", "kw3"],
         lifetime_days=1,
         max_assignments=num_recruits,
         notification_url="http://fake-domain{}".format(SNS_ROUTE_PATH),
         reward=0.01,
         title="fake experiment title",
         annotation="TEST_EXPERIMENT_UID",
         qualifications=[
             MTurkQualificationRequirements.min_approval(95),
             MTurkQualificationRequirements.restrict_to_countries(["US"]),
         ],
     )
Пример #4
0
def standard_hit_config(**kwargs):
    defaults = {
        "experiment_id": "some-experiment-id",
        "lifetime_days": 0.0004,  # 34 seconds (30 is minimum)
        "max_assignments": 1,
        "notification_url": "https://url-of-notification-route",
        "title": "Test Title",
        "keywords": ["testkw1", "testkw2"],
        "reward": 0.01,
        "question": MTurkQuestions.external(ad_url="https://url-of-ad-route"),
        "duration_hours": 0.25,
        "qualifications": [
            MTurkQualificationRequirements.min_approval(95),
            MTurkQualificationRequirements.restrict_to_countries(["US"]),
        ],
        "do_subscribe": False,
    }
    defaults.update(**kwargs)
    # Use fixed description, since this is how we clean up:
    defaults["description"] = TEST_HIT_DESCRIPTION + system_marker()

    return defaults
Пример #5
0
 def test_open_recruitment_with_explicit_qualifications(self, recruiter):
     recruiter.config.set(
         "mturk_qualification_requirements",
         u"""
         [
             {
                 "QualificationTypeId":"789RVWYBAZW00EXAMPLE",
                 "Comparator":"In",
                 "IntegerValues":[10, 20, 30]
             }
         ]
         """,
     )
     recruiter.open_recruitment(n=1)
     recruiter.mturkservice.create_hit.assert_called_once_with(
         question=MTurkQuestions.external(
             ad_url="http://fake-domain/ad?recruiter=mturk"),
         description="fake HIT description",
         duration_hours=1.0,
         experiment_id="TEST_EXPERIMENT_UID",
         lifetime_days=1,
         keywords=[u"kw1", u"kw2", u"kw3"],
         max_assignments=1,
         notification_url="http://fake-domain{}".format(SNS_ROUTE_PATH),
         reward=0.01,
         title="fake experiment title",
         annotation="TEST_EXPERIMENT_UID",
         qualifications=[
             MTurkQualificationRequirements.min_approval(95),
             MTurkQualificationRequirements.restrict_to_countries(["US"]),
             {
                 "QualificationTypeId": "789RVWYBAZW00EXAMPLE",
                 "Comparator": "In",
                 "IntegerValues": [10, 20, 30],
             },
         ],
     )