Changeset 552

Show
Ignore:
Timestamp:
11/17/04 01:49:15 (4 years ago)
Author:
dom
Message:

Disable some tests unless plucene is enabled. Default to plucene on for new installs.

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/Build.PL

    r540 r552  
    4242  variable => "custom_lib_path", 
    4343  }, 
    44 { question => "Do you want to use Plucene for searching? (recommended, but see Changes file before saying yes to this)", 
     44{ question => "Do you want to use Plucene for searching? (recommended, but see Changes file before saying yes to this if you are upgrading)", 
    4545  variable => "use_plucene", 
    46   default  => "n", 
     46  default  => "y", 
    4747  type     => "y_n" 
    4848  }, 
  • trunk/Changes

    r551 r552  
    55        Fixed a couple of minor bugs in the search - note that node.tt 
    66          and supersearch.tt have changed. 
     7        Change the default indexer for new installs to Plucene.  
     8        Only run certain search-related tests if Plucene is installed. 
    79 
    8100.43    21 October 2004 
  • trunk/t/22_rss_modwiki.t

    r550 r552  
    1010if ( $@ ) { 
    1111    plan skip_all => "DBD::SQLite not installed"; 
    12 } else { 
    13     plan tests => 7; 
     12    exit 0; 
     13} 
    1414 
    15     # Clear out the database from any previous runs. 
    16     unlink "t/node.db"; 
    17     unlink <t/indexes/*>; 
     15eval { require CGI::Wiki::Search::Plucene; }; 
     16if ( $@ ) { 
     17    plan skip_all => "Plucene not installed"; 
     18    exit 0; 
     19} 
    1820 
    19     CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
    20     my $config = Config::Tiny->new; 
    21     $config->{_} = { 
    22                      dbtype             => "sqlite", 
    23                      dbname             => "t/node.db", 
    24                      indexing_directory => "t/indexes", 
    25                      script_name        => "wiki.cgi", 
    26                      script_url         => "http://example.com/", 
    27                      site_name          => "Test Site", 
    28                      template_path      => "./templates", 
    29                      home_name          => "Home", 
    30                    }; 
     21plan tests => 7; 
    3122 
    32     # Plucene is the recommended searcher now. 
    33     eval { require CGI::Wiki::Search::Plucene; }; 
    34     unless ( $@ ) { 
    35         $config->{_}{use_plucene} = 1; 
    36     } 
     23# Clear out the database from any previous runs. 
     24unlink "t/node.db"; 
     25unlink <t/indexes/*>; 
    3726 
    38     # Basic sanity check first. 
    39     my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 
     27CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
     28my $config = Config::Tiny->new; 
     29$config->{_} = { 
     30                 dbtype             => "sqlite", 
     31                 dbname             => "t/node.db", 
     32                 indexing_directory => "t/indexes", 
     33                 script_name        => "wiki.cgi", 
     34                 script_url         => "http://example.com/", 
     35                 site_name          => "Test Site", 
     36                 template_path      => "./templates", 
     37                 home_name          => "Home", 
     38                 use_plucene        => 1 
     39               }; 
    4040 
    41     my $rdf_writer = OpenGuides::RDF->new( wiki   => $wiki, 
    42                                           config => $config ); 
     41# Basic sanity check first. 
     42my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 
    4343 
    44     my $rss = eval { $rdf_writer->make_recentchanges_rss; }; 
    45     is( $@, "", "->make_recentchanges_rss doesn't croak" ); 
     44my $rdf_writer = OpenGuides::RDF->new( wiki   => $wiki, 
     45                                       config => $config ); 
    4646 
    47     # Now write some data, first a minor edit then a non-minor one. 
    48     my $guide = OpenGuides->new( config => $config ); 
     47my $rss = eval { $rdf_writer->make_recentchanges_rss; }; 
     48is( $@, "", "->make_recentchanges_rss doesn't croak" ); 
     49 
     50# Now write some data, first a minor edit then a non-minor one. 
     51my $guide = OpenGuides->new( config => $config ); 
    4952     
    50     # Set up CGI parameters ready for a node write. 
    51     # Most of these are in here to avoid uninitialised value warnings. 
    52     my $q = CGI->new; 
    53     $q->param( -name => "content", -value => "foo" ); 
    54     $q->param( -name => "categories", -value => "" ); 
    55     $q->param( -name => "locales", -value => "" ); 
    56     $q->param( -name => "phone", -value => "" ); 
    57     $q->param( -name => "fax", -value => "" ); 
    58     $q->param( -name => "website", -value => "" ); 
    59     $q->param( -name => "hours_text", -value => "" ); 
    60     $q->param( -name => "address", -value => "" ); 
    61     $q->param( -name => "postcode", -value => "" ); 
    62     $q->param( -name => "map_link", -value => "" ); 
    63     $q->param( -name => "os_x", -value => "" ); 
    64     $q->param( -name => "os_y", -value => "" ); 
    65     $q->param( -name => "username", -value => "bob" ); 
    66     $q->param( -name => "comment", -value => "foo" ); 
    67     $q->param( -name => "edit_type", -value => "Minor tidying" ); 
    68     $ENV{REMOTE_ADDR} = "127.0.0.1"; 
     53# Set up CGI parameters ready for a node write. 
     54# Most of these are in here to avoid uninitialised value warnings. 
     55my $q = CGI->new; 
     56$q->param( -name => "content", -value => "foo" ); 
     57$q->param( -name => "categories", -value => "" ); 
     58$q->param( -name => "locales", -value => "" ); 
     59$q->param( -name => "phone", -value => "" ); 
     60$q->param( -name => "fax", -value => "" ); 
     61$q->param( -name => "website", -value => "" ); 
     62$q->param( -name => "hours_text", -value => "" ); 
     63$q->param( -name => "address", -value => "" ); 
     64$q->param( -name => "postcode", -value => "" ); 
     65$q->param( -name => "map_link", -value => "" ); 
     66$q->param( -name => "os_x", -value => "" ); 
     67$q->param( -name => "os_y", -value => "" ); 
     68$q->param( -name => "username", -value => "bob" ); 
     69$q->param( -name => "comment", -value => "foo" ); 
     70$q->param( -name => "edit_type", -value => "Minor tidying" ); 
     71$ENV{REMOTE_ADDR} = "127.0.0.1"; 
    6972 
    70     my $output = $guide->commit_node( 
    71                                       return_output => 1, 
    72                                       id => "Wombats", 
    73                                       cgi_obj => $q, 
    74                                     ); 
     73my $output = $guide->commit_node( 
     74                                  return_output => 1, 
     75                                  id => "Wombats", 
     76                                  cgi_obj => $q, 
     77                                ); 
    7578 
    76     $q->param( -name => "edit_type", -value => "Normal edit" ); 
    77     $output = $guide->commit_node( 
    78                                    return_output => 1, 
    79                                    id => "Badgers", 
    80                                    cgi_obj => $q, 
    81                                  ); 
     79$q->param( -name => "edit_type", -value => "Normal edit" ); 
     80$output = $guide->commit_node( 
     81                               return_output => 1, 
     82                               id => "Badgers", 
     83                               cgi_obj => $q, 
     84                             ); 
    8285 
    83     $q->param( -name => "username", -value => "Kake" ); 
    84     $output = $guide->commit_node( 
    85                                    return_output => 1, 
    86                                    id => "Wombles", 
    87                                    cgi_obj => $q, 
    88                                  ); 
     86$q->param( -name => "username", -value => "Kake" ); 
     87$output = $guide->commit_node( 
     88                               return_output => 1, 
     89                               id => "Wombles", 
     90                               cgi_obj => $q, 
     91                             ); 
    8992 
    90     # Check that the writes went in. 
    91     ok( $wiki->node_exists( "Wombats" ), "Wombats written" ); 
    92     ok( $wiki->node_exists( "Badgers" ), "Badgers written" ); 
    93     ok( $wiki->node_exists( "Wombles" ), "Wombles written" ); 
     93# Check that the writes went in. 
     94ok( $wiki->node_exists( "Wombats" ), "Wombats written" ); 
     95ok( $wiki->node_exists( "Badgers" ), "Badgers written" ); 
     96ok( $wiki->node_exists( "Wombles" ), "Wombles written" ); 
    9497 
    95     # Check that the minor edits can be filtered out. 
    96     $output = $guide->display_rss( 
    97                                    items              => 5, 
    98                                    username           => "bob", 
    99                                    ignore_minor_edits => 1, 
    100                                    return_output      => 1, 
    101                                  ); 
    102     unlike( $output, qr/Wombats/, "minor edits filtered out when required" ); 
    103     like( $output, qr/Badgers/, "but normal edits still in" ); 
     98# Check that the minor edits can be filtered out. 
     99$output = $guide->display_rss( 
     100                               items              => 5, 
     101                               username           => "bob", 
     102                               ignore_minor_edits => 1, 
     103                               return_output      => 1, 
     104                             ); 
     105unlike( $output, qr/Wombats/, "minor edits filtered out when required" ); 
     106like( $output, qr/Badgers/, "but normal edits still in" ); 
    104107 
    105     # Check that the username parameter is taken notice of. 
    106     unlike( $output, qr/Wombles/, "username parameter taken note of" ); 
    107 } 
     108# Check that the username parameter is taken notice of. 
     109unlike( $output, qr/Wombles/, "username parameter taken note of" ); 
  • trunk/t/36_supersearch_order.t

    r543 r552  
    88if ( $@ ) { 
    99    plan skip_all => "DBD::SQLite not installed"; 
    10 } else { 
    11     plan tests => 9; 
     10    exit 0; 
     11} 
    1212 
    13     # Clear out the database from any previous runs. 
    14     unlink "t/node.db"; 
    15     unlink <t/indexes/*>; 
     13eval { require CGI::Wiki::Search::Plucene; }; 
     14if ( $@ ) { 
     15    plan skip_all => "Plucene not installed"; 
     16    exit 0; 
     17} 
    1618 
    17     CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
    18     my $config = Config::Tiny->new; 
    19     $config->{_} = { 
    20                      dbtype             => "sqlite", 
    21                      dbname             => "t/node.db", 
    22                      indexing_directory => "t/indexes", 
    23                      script_name        => "wiki.cgi", 
    24                      script_url         => "http://example.com/", 
    25                      site_name          => "Test Site", 
    26                      template_path      => "./templates", 
    27                    }; 
     19plan tests => 9; 
    2820 
    29     # Plucene is the recommended searcher now. 
    30     eval { require CGI::Wiki::Search::Plucene; }; 
    31     unless ( $@ ) { 
    32         $config->{_}{use_plucene} = 1; 
    33     } 
     21# Clear out the database from any previous runs. 
     22unlink "t/node.db"; 
     23unlink <t/indexes/*>; 
    3424 
    35     my $search = OpenGuides::SuperSearch->new( config => $config ); 
    36     isa_ok( $search, "OpenGuides::SuperSearch" ); 
     25CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
     26my $config = Config::Tiny->new; 
     27$config->{_} = { 
     28                 dbtype             => "sqlite", 
     29                 dbname             => "t/node.db", 
     30                 indexing_directory => "t/indexes", 
     31                 script_name        => "wiki.cgi", 
     32                 script_url         => "http://example.com/", 
     33                 site_name          => "Test Site", 
     34                 template_path      => "./templates", 
     35                 use_plucene        => 1 
     36               }; 
    3737 
    38     # Write some data. 
    39     my $wiki = $search->{wiki}; 
    40     $wiki->write_node( "Parks", "A page about parks." ) 
    41         or die "Can't write node"; 
    42     $wiki->write_node( "Wandsworth Common", "A common.", undef, 
    43                        { category => "Parks" } ) 
    44         or die "Can't write node"; 
    45     $wiki->write_node( "Kake", "I like walking in parks." ) 
    46         or die "Can't write node"; 
     38my $search = OpenGuides::SuperSearch->new( config => $config ); 
     39isa_ok( $search, "OpenGuides::SuperSearch" ); 
    4740 
    48     my %tt_vars = $search->run( 
    49                                 return_tt_vars => 1, 
    50                                 vars           => { search => "parks" }, 
    51                               ); 
    52     foreach my $result ( @{ $tt_vars{results} || [] } ) { 
    53         print "# $result->{name} scores $result->{score}\n"; 
    54     } 
    55     my %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
    56     ok( $scores{Kake} < $scores{'Wandsworth Common'}, 
    57         "content match scores less than category match" ); 
    58     ok( $scores{'Wandsworth Common'} < $scores{Parks}, 
    59         "title match scores more than category match" ); 
     41# Write some data. 
     42my $wiki = $search->{wiki}; 
     43$wiki->write_node( "Parks", "A page about parks." ) 
     44    or die "Can't write node"; 
     45$wiki->write_node( "Wandsworth Common", "A common.", undef, 
     46                   { category => "Parks" } ) 
     47    or die "Can't write node"; 
     48$wiki->write_node( "Kake", "I like walking in parks." ) 
     49    or die "Can't write node"; 
    6050 
    61     # Now test locales. 
    62     $wiki->write_node( "Hammersmith", "A page about Hammersmith." ) 
    63         or die "Can't write node"; 
    64     $wiki->write_node( "The Gate", "A restaurant.", undef, 
    65                        { locale => "Hammersmith" } ) 
    66         or die "Can't write node"; 
    67     $wiki->write_node( "Kake Pugh", "I live in Hammersmith." ) 
    68         or die "Can't write node"; 
     51my %tt_vars = $search->run( 
     52                            return_tt_vars => 1, 
     53                            vars           => { search => "parks" }, 
     54                          ); 
     55foreach my $result ( @{ $tt_vars{results} || [] } ) { 
     56    print "# $result->{name} scores $result->{score}\n"; 
     57} 
     58my %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
     59ok( $scores{Kake} < $scores{'Wandsworth Common'}, 
     60    "content match scores less than category match" ); 
     61ok( $scores{'Wandsworth Common'} < $scores{Parks}, 
     62    "title match scores more than category match" ); 
    6963 
    70     %tt_vars = $search->run( 
    71                              return_tt_vars => 1, 
    72                              vars           => { search => "hammersmith" }, 
    73                            ); 
    74     foreach my $result ( @{ $tt_vars{results} || [] } ) { 
    75         print "# $result->{name} scores $result->{score}\n"; 
    76     } 
    77     %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
    78     ok( $scores{'Kake Pugh'} < $scores{'The Gate'}, 
    79         "content match scores less than locale match" ); 
    80     ok( $scores{'The Gate'} < $scores{Hammersmith}, 
    81         "locale match scores less than title match" ); 
     64# Now test locales. 
     65$wiki->write_node( "Hammersmith", "A page about Hammersmith." ) 
     66    or die "Can't write node"; 
     67$wiki->write_node( "The Gate", "A restaurant.", undef, 
     68                   { locale => "Hammersmith" } ) 
     69    or die "Can't write node"; 
     70$wiki->write_node( "Kake Pugh", "I live in Hammersmith." ) 
     71    or die "Can't write node"; 
    8272 
    83     # Check that two words in the title beats one in the title and 
    84     # one in the content. 
    85     $wiki->write_node( "Putney Tandoori", "Indian food" ) 
    86       or die "Couldn't write node"; 
    87     $wiki->write_node( "Putney", "There is a tandoori restaurant here" ) 
    88       or die "Couldn't write node"; 
     73%tt_vars = $search->run( 
     74                         return_tt_vars => 1, 
     75                         vars           => { search => "hammersmith" }, 
     76                       ); 
     77foreach my $result ( @{ $tt_vars{results} || [] } ) { 
     78    print "# $result->{name} scores $result->{score}\n"; 
     79} 
     80%scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
     81ok( $scores{'Kake Pugh'} < $scores{'The Gate'}, 
     82    "content match scores less than locale match" ); 
     83ok( $scores{'The Gate'} < $scores{Hammersmith}, 
     84    "locale match scores less than title match" ); 
    8985 
    90     %tt_vars = $search->run( 
    91                              return_tt_vars => 1, 
    92                              vars           => { search => "putney tandoori" }, 
    93                            ); 
    94     foreach my $result ( @{ $tt_vars{results} || [] } ) { 
    95         print "# $result->{name} scores $result->{score}\n"; 
    96     } 
    97     %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
    98     ok( $scores{Putney} < $scores{'Putney Tandoori'}, 
    99         "two words in title beats one in title and one in content" ); 
     86# Check that two words in the title beats one in the title and 
     87# one in the content. 
     88$wiki->write_node( "Putney Tandoori", "Indian food" ) 
     89  or die "Couldn't write node"; 
     90$wiki->write_node( "Putney", "There is a tandoori restaurant here" ) 
     91  or die "Couldn't write node"; 
    10092 
    101     SKIP: { 
    102         skip "Word proximity not yet taken into account", 1; 
    103     # Check that in an AND match words closer together get higher priority. 
    104     $wiki->write_node( "Spitalfields Market", 
    105                        "Mango juice from the Indian stall" ) 
    106       or die "Can't write node"; 
    107     $wiki->write_node( "Borough Market", "dried mango and real apple juice" ) 
    108       or die "Can't write node"; 
     93%tt_vars = $search->run( 
     94                         return_tt_vars => 1, 
     95                         vars           => { search => "putney tandoori" }, 
     96                       ); 
     97foreach my $result ( @{ $tt_vars{results} || [] } ) { 
     98    print "# $result->{name} scores $result->{score}\n"; 
     99} 
     100%scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
     101ok( $scores{Putney} < $scores{'Putney Tandoori'}, 
     102   "two words in title beats one in title and one in content" ); 
    109103 
    110     %tt_vars = $search->run( 
    111                              return_tt_vars => 1, 
    112                              vars           => { search => "mango juice" }, 
    113                            ); 
    114     foreach my $result ( @{ $tt_vars{results} || [] } ) { 
    115         print "# $result->{name} scores $result->{score}\n"; 
    116     } 
    117     %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
    118     ok( $scores{'Borough Market'} < $scores{'Spitalfields Market'}, 
    119         "words closer together gives higher score" ); 
    120     } # end of SKIP 
     104SKIP: { 
     105   skip "Word proximity not yet taken into account", 1; 
     106# Check that in an AND match words closer together get higher priority. 
     107$wiki->write_node( "Spitalfields Market", 
     108                   "Mango juice from the Indian stall" ) 
     109  or die "Can't write node"; 
     110$wiki->write_node( "Borough Market", "dried mango and real apple juice" ) 
     111  or die "Can't write node"; 
    121112 
    122     # Check that the number of occurrences of the search term is significant. 
     113%tt_vars = $search->run( 
     114                         return_tt_vars => 1, 
     115                         vars           => { search => "mango juice" }, 
     116                       ); 
     117foreach my $result ( @{ $tt_vars{results} || [] } ) { 
     118    print "# $result->{name} scores $result->{score}\n"; 
     119} 
     120%scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []}; 
     121ok( $scores{'Borough Market'} < $scores{'Spitalfields Market'}, 
     122    "words closer together gives higher score" ); 
     123} # end of SKIP 
    123124 
    124     $wiki->write_node( "Pub Crawls", "The basic premise of the pub crawl is to visit a succession of pubs, rather than spending the entire evening or day in a single establishment. London offers an excellent choice of themes for your pub crawl.", undef, { category => "Pubs" } ) or die "Can't write node"; 
    125     $wiki->write_node( "The Pub", "A pub.", undef, { category => "Pubs" } ) or die "Can't write node"; 
     125# Check that the number of occurrences of the search term is significant. 
    126126 
    127     %tt_vars = $search->run( 
    128                              return_tt_vars => 1, 
    129                              vars           => { search => "pub" } 
    130                            ); 
    131     foreach my $result ( @{ $tt_vars{results} || [] } ) { 
    132         print "# $result->{name} scores $result->{score}\n"; 
    133     } 
    134     is( $tt_vars{results}[0]{name}, "Pub Crawls", 
    135         "node with two mentions of search term comes top" ); 
    136     ok( $tt_vars{results}[0]{score} > $tt_vars{results}[1]{score}, 
    137         "...with a score strictly greater than node with one mention" ); 
     127$wiki->write_node( "Pub Crawls", "The basic premise of the pub crawl is to visit a succession of pubs, rather than spending the entire evening or day in a single establishment. London offers an excellent choice of themes for your pub crawl.", undef, { category => "Pubs" } ) or die "Can't write node"; 
     128$wiki->write_node( "The Pub", "A pub.", undef, { category => "Pubs" } ) or die "Can't write node"; 
    138129 
     130%tt_vars = $search->run( 
     131                         return_tt_vars => 1, 
     132                         vars           => { search => "pub" } 
     133                       ); 
     134foreach my $result ( @{ $tt_vars{results} || [] } ) { 
     135    print "# $result->{name} scores $result->{score}\n"; 
    139136} 
     137is( $tt_vars{results}[0]{name}, "Pub Crawls", 
     138    "node with two mentions of search term comes top" ); 
     139ok( $tt_vars{results}[0]{score} > $tt_vars{results}[1]{score}, 
     140    "...with a score strictly greater than node with one mention" ); 
  • trunk/t/38_supersearch_params.t

    r545 r552  
    99if ( $@ ) { 
    1010    plan skip_all => "DBD::SQLite not installed"; 
    11 } else { 
    12     plan tests => 4; 
     11    exit 0; 
     12} 
    1313 
    14     # Clear out the database from any previous runs. 
    15     unlink "t/node.db"; 
    16     unlink <t/indexes/*>; 
     14eval { require CGI::Wiki::Search::Plucene; }; 
     15if ( $@ ) {  
     16    plan skip_all => "Plucene not installed"; 
     17    exit 0; 
     18} 
    1719 
    18     CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
    19     my $config = Config::Tiny->new; 
    20     $config->{_} = { 
    21                      dbtype             => "sqlite", 
    22                      dbname             => "t/node.db", 
    23                      indexing_directory => "t/indexes", 
    24                      script_name        => "wiki.cgi", 
    25                      script_url         => "http://example.com/", 
    26                      site_name          => "Test Site", 
    27                      template_path      => "./templates", 
    28                    }; 
     20plan tests => 4; 
    2921 
    30     # Plucene is the recommended searcher now. 
    31     eval { require CGI::Wiki::Search::Plucene; }; 
    32     unless ( $@ ) { 
    33         $config->{_}{use_plucene} = 1; 
    34     } 
     22# Clear out the database from any previous runs. 
     23unlink "t/node.db"; 
     24unlink <t/indexes/*>; 
    3525 
    36     # Check we get the right distance when we supply OS co-ords. 
    37     my $search = OpenGuides::SuperSearch->new( config => $config ); 
    38     isa_ok( $search, "OpenGuides::SuperSearch" ); 
     26CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
     27my $config = Config::Tiny->new; 
     28$config->{_} = { 
     29                 dbtype             => "sqlite", 
     30                 dbname             => "t/node.db", 
     31                 indexing_directory => "t/indexes", 
     32                 script_name        => "wiki.cgi", 
     33                 script_url         => "http://example.com/", 
     34                 site_name          => "Test Site", 
     35                 template_path      => "./templates", 
     36                 use_plucene        => 1 
     37               }; 
    3938 
    40     my $q = CGI->new; 
    41     $q->param( -name => "os_x",         -value => 500000 ); 
    42     $q->param( -name => "os_y",         -value => 200000 ); 
    43     $q->param( -name => "os_dist",      -value => 500    ); 
    44     $q->param( -name => "latlong_dist", -value => 600    ); 
    45     my %vars = $q->Vars(); 
     39# Check we get the right distance when we supply OS co-ords. 
     40my $search = OpenGuides::SuperSearch->new( config => $config ); 
     41isa_ok( $search, "OpenGuides::SuperSearch" ); 
    4642 
    47     $search->run( vars => \%vars, return_output => 1 ); 
    48     is( $search->{distance_in_metres}, 500, 
    49         "os_dist picked up in pref. to latlong_dist when OS co-ords given" ); 
     43my $q = CGI->new; 
     44$q->param( -name => "os_x",         -value => 500000 ); 
     45$q->param( -name => "os_y",         -value => 200000 ); 
     46$q->param( -name => "os_dist",      -value => 500    ); 
     47$q->param( -name => "latlong_dist", -value => 600    ); 
     48my %vars = $q->Vars(); 
    5049 
    51     # Check we get the right distance when we supply lat/long. 
    52     $search = OpenGuides::SuperSearch->new( config => $config ); 
    53     isa_ok( $search, "OpenGuides::SuperSearch" ); 
     50$search->run( vars => \%vars, return_output => 1 ); 
     51is( $search->{distance_in_metres}, 500, 
     52    "os_dist picked up in pref. to latlong_dist when OS co-ords given" ); 
    5453 
    55     $q = CGI->new( "" ); 
    56     $q->param( -name => "lat",          -value => 51  ); 
    57     $q->param( -name => "long",         -value => 1   ); 
    58     $q->param( -name => "os_dist",      -value => 500 ); 
    59     $q->param( -name => "latlong_dist", -value => 600 ); 
    60     %vars = $q->Vars(); 
     54# Check we get the right distance when we supply lat/long. 
     55$search = OpenGuides::SuperSearch->new( config => $config ); 
     56isa_ok( $search, "OpenGuides::SuperSearch" ); 
    6157 
    62     $search->run( vars => \%vars, return_output => 1 ); 
    63     is( $search->{distance_in_metres}, 600, 
    64         "latlong_dist picked up in pref. to os_dist when lat/long given" ); 
    65 } 
     58$q = CGI->new( "" ); 
     59$q->param( -name => "lat",          -value => 51  ); 
     60$q->param( -name => "long",         -value => 1   ); 
     61$q->param( -name => "os_dist",      -value => 500 ); 
     62$q->param( -name => "latlong_dist", -value => 600 ); 
     63%vars = $q->Vars(); 
     64 
     65$search->run( vars => \%vars, return_output => 1 ); 
     66is( $search->{distance_in_metres}, 600, 
     67    "latlong_dist picked up in pref. to os_dist when lat/long given" );