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 unless $result; # ensure we have a result
|
||||||
|
|
||||||
return $result,
|
return $result, structured_answer => {
|
||||||
structured_answer => {
|
data => {
|
||||||
input => [$item], # or just the original query
|
title => $result,
|
||||||
operation => "Paleo Friendly",
|
subtitle => "Paleo Friendly: $item"
|
||||||
result => $result
|
},
|
||||||
|
templates => {
|
||||||
|
group => 'text'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,48 +9,26 @@ use DDG::Test::Goodie;
|
||||||
zci answer_type => "paleo_ingredient_check";
|
zci answer_type => "paleo_ingredient_check";
|
||||||
zci is_cached => 1;
|
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(
|
ddg_goodie_test(
|
||||||
[qw( DDG::Goodie::PaleoIngredientCheck )],
|
[qw( DDG::Goodie::PaleoIngredientCheck )],
|
||||||
'are apples paleo friendly' => test_zci(
|
'are apples paleo friendly' => build_test('Yes', "apples"),
|
||||||
'Yes',
|
'Is dairy allowed on the paleo diet?' => build_test('No', "dairy"),
|
||||||
structured_answer => {
|
'Is sugar paleo friendly?' => build_test("No", "sugar"),
|
||||||
input => ['apples'],
|
'beans paleo safe' => build_test("No", "beans"),
|
||||||
operation => 'Paleo Friendly',
|
'is sugar paleo' => build_test("No", "sugar"),
|
||||||
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',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
'Is foobar allowed on the paleo diet?' => undef,
|
'Is foobar allowed on the paleo diet?' => undef,
|
||||||
'are notarealfood paleo friendly' => undef,
|
'are notarealfood paleo friendly' => undef,
|
||||||
'paleo diet recipes' => undef,
|
'paleo diet recipes' => undef,
|
||||||
|
|
Loading…
Reference in New Issue