7 use SGN::Test::WWW::Mechanize skip_cgi => 1;
8 use SGN::Test::Data qw/ CXGN::Biosource::Schema create_test /;
10 my $mech = SGN::Test::WWW::Mechanize->new;
12 $mech->with_test_level( local => sub {
14 my $org = create_test( 'Organism::Organism' );
16 $mech->get( '/organism/'.uri_escape($org->species).'/genome' );
17 is $mech->status, 404, 'got a 404 if the organism has no genome_page organismprop';
19 # this prop will get cascade-deleted afterward
20 $org->create_organismprops({ genome_page => 1 }, { autocreate => 1 });
22 $mech->get_ok( '/organism/'.uri_escape($org->species).'/genome' );
23 $mech->content_contains( $org->species );
24 $mech->content_lacks( 'BLARG1', 'no assembly listed yet' );
26 my $genome_assembly_cvt = get_genome_assembly_cvt( $org->result_source->schema );
28 my $assembly = create_test('BsSample', {
29 sample_name => 'BLARG1',
30 description => 'First assembly of the Blargopodus genome',
31 type_id => $genome_assembly_cvt->cvterm_id,
32 organism_id => $org->organism_id,
35 $mech->get_ok( '/organism/'.uri_escape($org->species).'/genome' );
36 $mech->content_contains('BLARG1', 'BLARG1 assembly is listed');
38 my $annotation = create_test('BsSample', {
39 sample_name => 'ITAGblarg1',
40 description => 'annotation of the BLARG1 assembly by ITAG',
41 type_id => $genome_assembly_cvt->cvterm_id,
42 organism_id => $org->organism_id,
45 create_test('BsSampleRelationship', {
46 object => $annotation,
48 type => { name => 'annotates' },
51 $mech->get_ok( '/organism/'.uri_escape($org->species).'/genome' );
52 $mech->content_contains( 'BLARG1', 'BLARG1 assembly is listed');
53 $mech->content_contains( 'ITAGblarg1', 'ITAGblarg1 annotation is listed');
55 $mech->get_ok( '/genomes', 'got genome index page' );
56 $mech->content_contains( $org->species, 'genome index page contains the test species' );
60 $mech->get_ok( '/genomes', 'got genome index page ok' );
65 sub get_genome_assembly_cvt {
68 my $genome_assembly_cvt = $schema
70 ->search({ 'me.name' => 'sequence' })
71 ->search_related('cvterms', {
72 'cvterms.name' => 'reference_genome',
75 is $genome_assembly_cvt->count, 1;
76 $genome_assembly_cvt = $genome_assembly_cvt->first;
78 ok( $genome_assembly_cvt, "got reference_genome cvt ".eval {$genome_assembly_cvt->cvterm_id});
80 return $genome_assembly_cvt;