zeroclickinfo-goodies/t/BloodDonor.t

94 lines
2.8 KiB
Perl
Raw Normal View History

2013-11-14 07:00:38 -08:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
2013-11-14 07:00:38 -08:00
use DDG::Test::Goodie;
zci answer_type => "blood_donor";
zci is_cached => 1;
2013-11-14 07:00:38 -08:00
sub build_structure
{
my ($blood_type, $data, $keys) = @_;
return {
description => 'Returns available donors for a blood type',
meta => {
sourceName => 'Wikipedia',
sourceUrl => 'https://en.wikipedia.org/wiki/Blood_type'
},
templates => {
group => 'list',
options => {
content => 'record'
}
},
data => {
title => "Donors for blood type $blood_type",
record_data => $data,
record_keys => $keys
}
};
}
2013-11-14 07:00:38 -08:00
ddg_goodie_test(
2014-05-08 14:05:09 -07:00
['DDG::Goodie::BloodDonor'],
'donor A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
structured_answer => build_structure("A+",{
"Ideal donor" => "A+",
"Other donors" => "A+ or O+",
"Only if no Rh(+) found" => "A- or O-"
},
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
)
),
'donors for A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
structured_answer => build_structure("A+",{
"Ideal donor" => "A+",
"Other donors" => "A+ or O+",
"Only if no Rh(+) found" => "A- or O-"
},
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
)
),
'blood donor A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
structured_answer => build_structure("A+",{
"Ideal donor" => "A+",
"Other donors" => "A+ or O+",
"Only if no Rh(+) found" => "A- or O-"
},
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
)
),
'blood donors for A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
structured_answer => build_structure("A+",{
"Ideal donor" => "A+",
"Other donors" => "A+ or O+",
"Only if no Rh(+) found" => "A- or O-"
},
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
)
),
'donor o+' => test_zci("Ideal donor: O+\nOther donors: O+\nOnly if no Rh(+) found: O-",
structured_answer => build_structure("O+",{
"Ideal donor" => "O+",
"Other donors" => "O+",
"Only if no Rh(+) found" => "O-"
},
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
)
),
2015-12-06 20:56:48 -08:00
'donor o+ve' => test_zci("Ideal donor: O+VE\nOther donors: O+ve\nOnly if no Rh(+) found: O-ve",
structured_answer => build_structure("O+VE",{
"Ideal donor" => "O+VE",
"Other donors" => "O+ve",
"Only if no Rh(+) found" => "O-ve"
},
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
)
),
2013-11-14 07:00:38 -08:00
);
2016-05-16 06:18:04 -07:00
done_testing;