1 #test all functions in CXGN::Stock::Accession
9 use SGN::Test::Fixture;
10 use CXGN::Stock::Accession;
12 my $f = SGN::Test::Fixture->new();
13 my $schema = $f->bcs_schema();
15 my $main_production_site_url = 'http://localhost';
16 my $stock1_uniquename = 'stock1testuniquename';
17 my $stock1_name = 'stock1testname';
18 my $stock1_org_name = 'stock1testorg';
19 my $stock1_pop_name = 'stock1testpop';
20 my $stock1_desc = 'stock1testdesc';
21 my $species = 'Manihot esculenta';
22 my $stock1_accession_number = 'stock1testacc';
23 my $stock1_pui = "$main_production_site_url/stock/123";
24 #my $stock1_pedigree = "test_accession1/test_accession2";
25 my $stock1_source = "stock1testsource";
26 my $stock1_synonyms = ["stock1testsyn", "stock1testsyn2"];
27 my $stock1_inst = "stock1testinst";
28 my $stock1_inst_name = "stock1testinstname";
29 my $stock1_bio = "stock1testbio";
30 my $stock1_country = "stock1testcountry";
31 my $stock1_storage = "stock1teststorage";
32 my $stock1_date = "stock1testdate";
34 { 'donorGermplasmName'=>'stock1_donor1', 'donorAccessionNumber' => 'stock1_donor1', 'donorInstituteCode'=>'stock1_donorinst1', 'germplasmPUI'=>'stock1_donorpui1' },
35 { 'donorGermplasmName'=>'stock1_donor2', 'donorAccessionNumber' => 'stock1_donor2', 'donorInstituteCode'=>'stock1_donorinst2', 'germplasmPUI'=>'stock1_donorpui2' }
38 my $stock1 = CXGN::Stock::Accession->new({
40 main_production_site_url=>$main_production_site_url,
45 uniquename=>$stock1_uniquename,
46 organization_name=>$stock1_org_name,
47 population_name=>$stock1_pop_name,
48 description=>$stock1_desc,
49 accessionNumber=>$stock1_accession_number,
50 germplasmPUI=>$stock1_pui,
51 #pedigree=>$stock1_pedigree,
52 germplasmSeedSource=>$stock1_source,
53 synonyms=>$stock1_synonyms,
54 #commonCropName=>$_->{commonCropName},
55 instituteCode=>$stock1_inst,
56 instituteName=>$stock1_inst_name,
57 biologicalStatusOfAccessionCode=>$stock1_bio,
58 countryOfOriginCode=>$stock1_country,
59 typeOfGermplasmStorageCode=>$stock1_storage,
60 #speciesAuthority=>$_->{speciesAuthority},
61 #subtaxa=>$_->{subtaxa},
62 #subtaxaAuthority=>$_->{subtaxaAuthority},
63 donors=>$stock1donors,
64 acquisitionDate=>$stock1_date
66 my $stock_id1 = $stock1->store();
68 my $s = CXGN::Stock::Accession->new(schema=>$schema, stock_id=>$stock_id1);
69 is($s->uniquename, $stock1_uniquename);
70 is($s->name, $stock1_name);
71 is($s->organization_name, $stock1_org_name);
72 is_deeply($s->population_name, $stock1_pop_name);
73 is($s->description, $stock1_desc);
74 is($s->type, 'accession');
75 is($s->accessionNumber, $stock1_accession_number);
76 is($s->germplasmPUI, "$main_production_site_url/stock/$stock_id1/view,".$stock1_pui);
77 is($s->germplasmSeedSource, $stock1_source);
78 print STDERR Dumper $s->synonyms;
79 is_deeply($s->synonyms, $stock1_synonyms);
80 is($s->instituteCode, $stock1_inst);
81 is($s->instituteName, $stock1_inst_name);
82 is($s->biologicalStatusOfAccessionCode, $stock1_bio);
83 is($s->countryOfOriginCode, $stock1_country);
84 is($s->typeOfGermplasmStorageCode, $stock1_storage);
85 is($s->acquisitionDate, $stock1_date);
86 print STDERR Dumper $s->donors;
87 is_deeply($s->donors, $stock1donors);
89 my $stock2_uniquename = 'stock2testuniquename';
90 my $stock2_name = 'stock2testname';
91 my $stock2_org_name = 'stock2testorg';
92 my $stock2_pop_name = 'stock2testpop';
93 my $stock2_desc = 'stock2testdesc';
94 my $stock2_accession_number = 'stock2testacc';
95 #my $stock2_pedigree = "test_accession1/test_accession2";
96 my $stock2_source = "stock2testsource";
97 my $stock2_synonyms = ["stock2testsyn", "stock2testsyn2"];
98 my $stock2_inst = "stock2testinst";
99 my $stock2_inst_name = "stock2testinstname";
100 my $stock2_bio = "stock2testbio";
101 my $stock2_country = "stock2testcountry";
102 my $stock2_storage = "stock2teststorage";
103 my $stock2_date = "stock2testdate";
105 { 'donorGermplasmName'=>'stock2_donor1', 'donorAccessionNumber' => 'stock2_donor1', 'donorInstituteCode'=>'stock2_donorinst1', 'germplasmPUI'=>'stock2_donorpui1' },
106 { 'donorGermplasmName'=>'stock2_donor2', 'donorAccessionNumber' => 'stock2_donor2', 'donorInstituteCode'=>'stock2_donorinst2', 'germplasmPUI'=>'stock2_donorpui2' }
109 my $stock2 = CXGN::Stock::Accession->new({
111 main_production_site_url=>$main_production_site_url,
116 uniquename=>$stock2_uniquename,
117 organization_name=>$stock2_org_name,
118 population_name=>$stock2_pop_name,
119 description=>$stock2_desc,
120 accessionNumber=>$stock2_accession_number,
121 #pedigree=>$stock2_pedigree,
122 germplasmSeedSource=>$stock2_source,
123 synonyms=>$stock2_synonyms,
124 #commonCropName=>$_->{commonCropName},
125 instituteCode=>$stock2_inst,
126 instituteName=>$stock2_inst_name,
127 biologicalStatusOfAccessionCode=>$stock2_bio,
128 countryOfOriginCode=>$stock2_country,
129 typeOfGermplasmStorageCode=>$stock2_storage,
130 #speciesAuthority=>$_->{speciesAuthority},
131 #subtaxa=>$_->{subtaxa},
132 #subtaxaAuthority=>$_->{subtaxaAuthority},
133 donors=>$stock2donors,
134 acquisitionDate=>$stock2_date
136 my $stock_id2 = $stock2->store();
138 my $s = CXGN::Stock::Accession->new(schema=>$schema, stock_id=>$stock_id2);
139 is($s->uniquename, $stock2_uniquename);
140 is($s->name, $stock2_name);
141 is($s->organization_name, $stock2_org_name);
142 is_deeply($s->population_name, $stock2_pop_name);
143 is($s->description, $stock2_desc);
144 is($s->type, 'accession');
145 is($s->accessionNumber, $stock2_accession_number);
146 is($s->germplasmPUI, "$main_production_site_url/stock/$stock_id2/view");
147 is($s->germplasmSeedSource, $stock2_source);
148 is_deeply($s->synonyms, $stock2_synonyms);
149 is($s->instituteCode, $stock2_inst);
150 is($s->instituteName, $stock2_inst_name);
151 is($s->biologicalStatusOfAccessionCode, $stock2_bio);
152 is($s->countryOfOriginCode, $stock2_country);
153 is($s->typeOfGermplasmStorageCode, $stock2_storage);
154 is($s->acquisitionDate, $stock2_date);
155 is_deeply($s->donors, $stock2donors);