PaleoIngredientCheck: Converting to text template
parent
24755a1018
commit
463027d896
|
@ -38,11 +38,14 @@ handle remainder => sub {
|
|||
|
||||
return unless $result; # ensure we have a result
|
||||
|
||||
return $result,
|
||||
structured_answer => {
|
||||
input => [$item], # or just the original query
|
||||
operation => "Paleo Friendly",
|
||||
result => $result
|
||||
return $result, structured_answer => {
|
||||
data => {
|
||||
title => $result,
|
||||
subtitle => "Paleo Friendly: $item"
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -9,48 +9,26 @@ use DDG::Test::Goodie;
|
|||
zci answer_type => "paleo_ingredient_check";
|
||||
zci is_cached => 1;
|
||||
|
||||
sub build_test {
|
||||
my ($text, $input) = @_;
|
||||
return test_zci($text, structured_answer =>{
|
||||
data => {
|
||||
title => $text,
|
||||
subtitle => "Paleo Friendly: $input"
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::PaleoIngredientCheck )],
|
||||
'are apples paleo friendly' => test_zci(
|
||||
'Yes',
|
||||
structured_answer => {
|
||||
input => ['apples'],
|
||||
operation => 'Paleo Friendly',
|
||||
result => 'Yes',
|
||||
},
|
||||
),
|
||||
'Is dairy allowed on the paleo diet?' => test_zci(
|
||||
'No',
|
||||
structured_answer => {
|
||||
input => ['dairy'],
|
||||
operation => 'Paleo Friendly',
|
||||
result => 'No',
|
||||
},
|
||||
),
|
||||
'Is sugar paleo friendly?' => test_zci(
|
||||
'No',
|
||||
structured_answer => {
|
||||
input => ['sugar'],
|
||||
operation => 'Paleo Friendly',
|
||||
result => 'No',
|
||||
},
|
||||
),
|
||||
'beans paleo safe' => test_zci(
|
||||
'No',
|
||||
structured_answer => {
|
||||
input => ['beans'],
|
||||
operation => 'Paleo Friendly',
|
||||
result => 'No',
|
||||
},
|
||||
),
|
||||
'is sugar paleo' => test_zci(
|
||||
'No',
|
||||
structured_answer => {
|
||||
input => ['sugar'],
|
||||
operation => 'Paleo Friendly',
|
||||
result => 'No',
|
||||
},
|
||||
),
|
||||
'are apples paleo friendly' => build_test('Yes', "apples"),
|
||||
'Is dairy allowed on the paleo diet?' => build_test('No', "dairy"),
|
||||
'Is sugar paleo friendly?' => build_test("No", "sugar"),
|
||||
'beans paleo safe' => build_test("No", "beans"),
|
||||
'is sugar paleo' => build_test("No", "sugar"),
|
||||
'Is foobar allowed on the paleo diet?' => undef,
|
||||
'are notarealfood paleo friendly' => undef,
|
||||
'paleo diet recipes' => undef,
|
||||
|
|
Loading…
Reference in New Issue