1#!/usr/bin/perl 2use strict; 3use warnings; 4use Test::More; 5BEGIN { push(@INC, "lib", "t"); } 6use Net::Amazon::MechanicalTurk; 7use Net::Amazon::MechanicalTurk::Command::LoadHITs; 8use Net::Amazon::MechanicalTurk::Command::UpdateHITs; 9use TestHelper; 10 11my $mturk = TestHelper->new; 12 13if (!$ENV{MTURK_TEST_WRITABLE}) { 14 plan skip_all => "Set environment variable MTURK_TEST_WRITABLE=1 to enable tests which have side-effects."; 15} 16else { 17 plan tests => 1; 18} 19 20sub renderQuestion { 21 my ($params) = @_; 22 return <<END_XML; 23<?xml version="1.0" encoding="UTF-8"?> 24<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd"> 25 <Question> 26 <QuestionIdentifier>1</QuestionIdentifier> 27 <QuestionContent> 28 <Text>$params->{question}</Text> 29 </QuestionContent> 30 <AnswerSpecification> 31 <FreeTextAnswer/> 32 </AnswerSpecification> 33 </Question> 34</QuestionForm> 35END_XML 36} 37 38my $hitInput = [ 39 { question => 'Where are you now?' }, 40 { question => 'Where were you yesterday?' }, 41 { question => 'What is your name?' }, 42]; 43 44my $properties = { 45 Title => 'Answer a question', 46 Description => 'Test HIT from Perl', 47 Keywords => 'hello, world, command, sample', 48 Reward => { 49 CurrencyCode => 'USD', 50 Amount => 0.01 51 }, 52 RequesterAnnotation => 'Test Hit', 53 AssignmentDurationInSeconds => 60 * 60, 54 AutoApprovalDelayInSeconds => 60 * 60 * 10, 55 MaxAssignments => 3, 56 LifetimeInSeconds => 60 * 60 57}; 58 59my $properties2 = { 60 Title => 'Answer a revised question', 61 Description => 'Test HIT from Perl', 62 Keywords => 'hello, world, command, sample, changehittypeofhit', 63 Reward => { 64 CurrencyCode => 'USD', 65 Amount => 0.02 66 }, 67 RequesterAnnotation => 'Test Hit', 68 AssignmentDurationInSeconds => 60 * 60, 69 AutoApprovalDelayInSeconds => 60 * 60 * 10, 70}; 71 72$mturk->loadHITs( 73 properties => $properties, 74 input => $hitInput, 75 question => \&renderQuestion, 76 #progress => \*STDERR, 77 success => "t/data/78.generatedhits.txt", 78 fail => "t/data/78.failed.txt" 79); 80 81$mturk->updateHITs( 82 properties => $properties2, 83 input => "t/data/78.generatedhits.txt", 84 #progress => \*STDERR, 85 success => "t/data/78.updatedhits.txt", 86 fail => "t/data/78.updatefailed.txt", 87); 88 89ok(1, "updateHITs"); 90 91