Add new MapPoint code for geolocation, Thingy searching and indexing and a macro for rendering thing data outside of the Thingy.
This commit is contained in:
parent
944c76040a
commit
61534779d5
24 changed files with 1442 additions and 176 deletions
|
|
@ -40,7 +40,7 @@ WebGUI::Test->addToCleanup(
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 16; # Increment this number for each test you create
|
||||
plan tests => 24; # Increment this number for each test you create
|
||||
|
||||
use_ok( 'WebGUI::Search::Index' );
|
||||
|
||||
|
|
@ -72,6 +72,7 @@ cmp_deeply (
|
|||
re("keyword1"), re("keyword2"),
|
||||
),
|
||||
lineage => $article->get('lineage'),
|
||||
subId => undef,
|
||||
},
|
||||
"Index has correct information"
|
||||
);
|
||||
|
|
@ -84,7 +85,7 @@ is( $indexer->getId, $article->getId, "getId() returns assetId" );
|
|||
|
||||
# setIsPublic
|
||||
$indexer->setIsPublic(0);
|
||||
is( $db->quickScalar( "SELECT isPublic FROM assetIndex WHERE assetId=?", [$article->getId] ),
|
||||
is( $db->quickScalar( "SELECT isPublic FROM assetIndex WHERE assetId=? and url=?", [$article->getId, $article->get('url')] ),
|
||||
0,
|
||||
"setIsPublic updates database",
|
||||
);
|
||||
|
|
@ -94,7 +95,7 @@ isa_ok( $indexer->session, 'WebGUI::Session', 'session returns session' );
|
|||
|
||||
# updateSynopsis
|
||||
$indexer->updateSynopsis( "A new synopsis" );
|
||||
is( $db->quickScalar( "SELECT synopsis FROM assetIndex WHERE assetId=?", [$article->getId] ),
|
||||
is( $db->quickScalar( "SELECT synopsis FROM assetIndex WHERE assetId=? and url=?", [$article->getId, $article->get('url')] ),
|
||||
"A new synopsis",
|
||||
"updateSynopsis updates assetIndex"
|
||||
);
|
||||
|
|
@ -109,9 +110,9 @@ isnt(
|
|||
# TODO
|
||||
|
||||
# addKeywords
|
||||
my $currentKeywords = $db->quickScalar( "SELECT keywords FROM assetIndex WHERE assetId=?", [$article->getId] );
|
||||
my $currentKeywords = $db->quickScalar( "SELECT keywords FROM assetIndex WHERE assetId=? and url=?", [$article->getId, $article->get('url')] );
|
||||
$indexer->addKeywords("shawshank");
|
||||
my $newKeywords = $db->quickScalar( "SELECT keywords FROM assetIndex WHERE assetId=?", [$article->getId] );
|
||||
my $newKeywords = $db->quickScalar( "SELECT keywords FROM assetIndex WHERE assetId=? and url=?", [$article->getId, $article->get('url')] );
|
||||
like( $newKeywords, qr{$currentKeywords}, "addKeywords keeps old keywords" );
|
||||
like( $newKeywords, qr{shawshank}, "addKeywords adds the keywords" );
|
||||
|
||||
|
|
@ -123,7 +124,7 @@ $article->update({
|
|||
} );
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
|
||||
ok ( $row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=?", [ $article->getId ] ),
|
||||
ok ( $row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=? and url=?", [ $article->getId, $article->get('url') ] ),
|
||||
"assetId exists in assetIndex"
|
||||
);
|
||||
cmp_deeply (
|
||||
|
|
@ -148,6 +149,7 @@ cmp_deeply (
|
|||
re("keyword1"), re("keyword2"),
|
||||
),
|
||||
lineage => $article->get('lineage'),
|
||||
subId => undef,
|
||||
},
|
||||
"Index has synopsis information in keywords"
|
||||
);
|
||||
|
|
@ -161,7 +163,7 @@ $article->update({
|
|||
});
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=?", [ $article->getId ]);
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=? and url=?", [ $article->getId, $article->get('url') ]);
|
||||
cmp_deeply (
|
||||
$row,
|
||||
{
|
||||
|
|
@ -184,6 +186,7 @@ cmp_deeply (
|
|||
re("keyword1"), re("keyword2"),
|
||||
),
|
||||
lineage => $article->get('lineage'),
|
||||
subId => undef,
|
||||
},
|
||||
"Index has description in keywords"
|
||||
);
|
||||
|
|
@ -197,7 +200,7 @@ $article->update({
|
|||
});
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=?", [ $article->getId ] );
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=? and url=?", [ $article->getId, $article->get('url') ] );
|
||||
cmp_deeply (
|
||||
$row,
|
||||
{
|
||||
|
|
@ -219,6 +222,7 @@ cmp_deeply (
|
|||
re("keyword1"), re("keyword2"),
|
||||
),
|
||||
lineage => $article->get('lineage'),
|
||||
subId => undef,
|
||||
},
|
||||
"Index has synopsis and description in keywords"
|
||||
);
|
||||
|
|
@ -230,7 +234,7 @@ $article->update({
|
|||
});
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=?", [ $article->getId ] );
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=? and url=?", [ $article->getId, $article->get('url') ] );
|
||||
cmp_deeply (
|
||||
$row,
|
||||
superhashof({
|
||||
|
|
@ -256,7 +260,7 @@ SKIP: {
|
|||
});
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=?", [ $article->getId ] );
|
||||
$row = $db->quickHashRef( "SELECT * FROM assetIndex WHERE assetId=? and url=?", [ $article->getId, $article->get('url') ] );
|
||||
cmp_deeply (
|
||||
$row,
|
||||
superhashof({
|
||||
|
|
@ -270,4 +274,39 @@ SKIP: {
|
|||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test addRecord
|
||||
note "addRecord";
|
||||
$article->update({
|
||||
description => "descriptive",
|
||||
});
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
is $session->db->quickScalar('select count(*) from assetIndex where assetId=?', [$article->getId]), 1, 'create puts 1 record into the db';
|
||||
$indexer->addRecord( url => 'something else');
|
||||
is $session->db->quickScalar('select count(*) from assetIndex where assetId=?', [$article->getId]), 1, 'addRecord does nothing without url and keywords entries';
|
||||
$indexer->addRecord( keywords => 'something else');
|
||||
is $session->db->quickScalar('select count(*) from assetIndex where assetId=?', [$article->getId]), 1, 'addRecord does nothing without url and keywords entries';
|
||||
$indexer->addRecord( keywords => 'something else', url => '', );
|
||||
is $session->db->quickScalar('select count(*) from assetIndex where assetId=?', [$article->getId]), 1, 'addRecord does nothing without url and keywords entries';
|
||||
$indexer->addRecord( keywords => 'something else', url => 'another/thing/coming', );
|
||||
is $session->db->quickScalar('select count(*) from assetIndex where assetId=?', [$article->getId]), 2, 'new record added';
|
||||
|
||||
my %original_record = $session->db->quickHash('select * from assetIndex where assetId=? and url=?', [$article->getId, $article->get('url')]);
|
||||
my %new_record = $session->db->quickHash('select * from assetIndex where assetId=? and url=?', [$article->getId, 'another/thing/coming']);
|
||||
|
||||
delete @original_record{qw/url keywords/};
|
||||
delete @new_record{qw/url keywords/};
|
||||
|
||||
cmp_deeply(\%original_record, \%new_record, 'records are the same, aside from url and keywords');
|
||||
|
||||
$indexer->delete;
|
||||
is $session->db->quickScalar('select count(*) from assetIndex where assetId=?', [$article->getId]), 0, 'all records deleted';
|
||||
|
||||
$indexer = WebGUI::Search::Index->create( $article );
|
||||
$indexer->addRecord(url => 'other', keywords => 'yada yada yada', lineage => 'hike');
|
||||
my %original_record = $session->db->quickHash('select * from assetIndex where assetId=? and url=?', [$article->getId, $article->get('url')]);
|
||||
my %new_record = $session->db->quickHash('select * from assetIndex where assetId=? and url=?', [$article->getId, 'other']);
|
||||
|
||||
is $original_record{lineage}, $new_record{lineage}, 'lineage is not allowed to be overridden';
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue