start fixing test for multi cat phenotype upload.
[sgn.git] / t / unit_fixture / CXGN / BreederSearch.t
blob7d324b5c996af13278041c32c30d616acd80c82d
2 use strict;
4 use lib 't/lib';
6 use Test::More;
7 use SGN::Test::Fixture;
8 use CXGN::BreederSearch;
9 use Data::Dumper;
11 my $f = SGN::Test::Fixture->new();
13 my $bs = CXGN::BreederSearch->new( { dbh=> $f->dbh() });
15 my $criteria_list = [
16                'years'
17              ];
18 my $dataref = {};
19 my $queryref = {};
21 my $results = $bs->metadata_query($criteria_list, $dataref, $queryref);
22 print STDERR Dumper $results;
23 is_deeply($results, {
24                'results' => [
25                               [
26                                 '2014',
27                                 '2014'
28                               ],
29                               [
30                                 '2015',
31                                 '2015'
32                               ],
33                               [
34                                 '2016',
35                                 '2016'
36                               ],
37                               [
38                                 '2017',
39                                 '2017'
40                               ],
42                             ]
43              }, 'wizard one category query');
45 $criteria_list = [
46                'years',
47                'locations'
48              ];
49 $dataref = {
50                'locations' => {
51                               'years' => '\'2014\''
52                             }
53              };
54 $queryref = {
55                'locations' => {
56                               'years' => 0
57                             }
58              };
60 $results = $bs->metadata_query($criteria_list, $dataref, $queryref);
61 is_deeply($results, {
62                'results' => [
63                               [
64                                 23,
65                                 'test_location'
66                               ]
67                             ]
68              }, "wizard two category query" );
70 $criteria_list = [
71                'years',
72                'locations',
73                'trials'
74              ];
75 $dataref = {
76                'trials' => {
77                            'locations' => '\'23\'',
78                            'years' => '\'2014\''
79                          }
80              };
81 $queryref = {
82                'trials' => {
83                            'locations' => 0,
84                            'years' => 0
85                          }
86              };
87 $results = $bs ->metadata_query($criteria_list, $dataref, $queryref);
88 is_deeply($results, {
89                'results' => [
90                               [
91                                 139,
92                                 'Kasese solgs trial'
93                               ],
94                               [
95                                 137,
96                                 'test_trial'
97                               ],
98                               [
99                                 141,
100                                 'trial2 NaCRRI'
101                               ]
102                             ]
103              }, "wizard three category query");
105 $criteria_list = [
106                'years',
107                'locations',
108                'trials',
109                'genotyping_protocols'
110              ];
111 $dataref = {
112                'genotyping_protocols' => {
113                                          'trials' => '\'139\'',
114                                          'locations' => '\'23\'',
115                                          'years' => '\'2014\''
116                                        }
117              };
118 $queryref = {
119                'genotyping_protocols' => {
120                                          'trials' => 0,
121                                          'locations' => 0,
122                                          'years' => 0
123                                        }
124              };
125 $results = $bs ->metadata_query($criteria_list, $dataref, $queryref);
126 is_deeply($results, {
127                'results' => [
128                               [
129                                 1,
130                                 'GBS ApeKI genotyping v4'
131                               ]
132                             ]
133              }, "wizard four category query");
135 $criteria_list = [
136                'breeding_programs',
137                'trials',
138                'traits'
139              ];
140 $dataref = {
141                'traits' => {
142                            'trials' => '\'139\',\'141\'',
143                            'breeding_programs' => '\'134\''
144                          }
145              };
146 $queryref = {
147                'traits' => {
148                            'trials' => 1,
149                            'breeding_programs' => 0
150                          }
151              };
152 $results = $bs ->metadata_query($criteria_list, $dataref, $queryref);
153 is_deeply($results, {
154                'results' => [
155                               [
156                                 70741,
157                                 'dry matter content percentage|CO_334:0000092'
158                               ],
159                               [
160                                 70666,
161                                 'fresh root weight|CO_334:0000012'
162                               ],
163                               [
164                                 70773,
165                                 'fresh shoot weight measurement in kg|CO_334:0000016'
166                               ]
167                             ]
168              }, "wizard intersect query");
170 $criteria_list = [
171                'trials',
172                'accessions',
173                'plots'
174              ];
175 $dataref = {
176                'plots' => {
177                           'trials' => '\'137\'',
178                           'accessions' => '\'38840\',\'38841\''
179                         }
180              };
181 $queryref = {
182                'plots' => {
183                           'trials' => 0,
184                           'accessions' => 1
185                         }
186              };
187 $results = $bs ->metadata_query($criteria_list, $dataref, $queryref);
188 is_deeply($results, {
189                'results' => []
190              }, "wizard 0 results error query");
193 $criteria_list = [
194   'trials',
195   'accessions'
197 $dataref = {
198   'accessions' => {
199     'trials' => '\'137\', \'139\', \'141\''
200   }
202 $queryref = {
203   'accessions' => {
204     'trials' => 0.5
205   }
207 $results = $bs ->metadata_query($criteria_list, $dataref, $queryref);
208 is(scalar(@{$results->{'results'}}), 254, "wizard min match query");
210 done_testing();