6 use SGN::Test::Fixture;
7 use CXGN::Trial::ParseUpload;
10 my $f = SGN::Test::Fixture->new();
12 for my $extension ("xls", "xlsx") {
14 my $p = CXGN::Trial::ParseUpload->new({ filename => "t/data/genotype_trial_upload/CASSAVA_GS_74Template.csv", chado_schema => $f->bcs_schema() });
15 $p->load_plugin("ParseIGDFile");
17 my $results = $p->parse();
18 my $errors = $p->get_parse_errors();
20 ok(scalar(@{$errors->{'error_messages'}}) == 0, "no parse errors");
22 is_deeply($results, { trial_name => "CASSAVA_GS_74", blank_well => "F05", user_id => 'I.Rabbi@cgiar.org', project_name => 'NEXTGENCASSAVA' }, "parse results test");
24 #print STDERR join ",", @{$errors->{'error_messages'}};
26 $p = CXGN::Trial::ParseUpload->new({ filename => "t/data/genotype_trial_upload/CASSAVA_GS_74Template_missing_blank.csv", chado_schema => $f->bcs_schema() });
27 $p->load_plugin("ParseIGDFile");
29 $results = $p->parse();
30 $errors = $p->get_parse_errors();
32 ok($errors->{'error_messages'}->[0] eq "No blank well found in spreadsheet", "detect missing blank entry");
34 $p = CXGN::Trial::ParseUpload->new({ filename => "t/data/genotype_trial_upload/CASSAVA_GS_74Template_messed_up_trial_name.csv", chado_schema => $f->bcs_schema() });
35 $p->load_plugin("ParseIGDFile");
37 $results = $p->parse();
38 $errors = $p->get_parse_errors();
40 ok($errors->{'error_messages'}->[0] eq "All trial names in the trial column must be identical", "detect messed up trial name");
42 $p = CXGN::Trial::ParseUpload->new({ filename => "t/data/trial/trial_layout_bad_accessions.$extension", chado_schema => $f->bcs_schema() });
43 $p->load_plugin("TrialExcelFormat");
45 $results = $p->parse();
46 $errors = $p->get_parse_errors();
47 #print STDERR Dumper $errors;
48 ok($errors->{'error_messages'}->[0] =~ /The following entry names are not in the database as uniquenames or synonyms/, 'check that accessions not in db');
49 ok(scalar(@{$errors->{'error_messages'}}) == 1, 'check that accessions not in db');
50 ok(scalar(@{$errors->{'missing_stocks'}}) == 8, 'check that accessions not in db');
52 $p = CXGN::Trial::ParseUpload->new({ filename => "t/data/genotype_trial_upload/CASSAVA_GS_74Template_messed_up_trial_name.csv", chado_schema => $f->bcs_schema() });
53 $p->load_plugin("TrialExcelFormat");
55 $results = $p->parse();
56 $errors = $p->get_parse_errors();
57 ok($errors->{'error_messages'}->[0] eq "No Excel data found in file", 'check that accessions not in db');