Merge branch 'master' into topic/simple_image_upload
[sgn.git] / t / unit_mech / Controller / Project / Secretom / Secretary.t
blob8125daf065253921f5143930a278e9b643cdef12
1 use strict;
2 use warnings;
3 use Test::More;
5 use HTTP::Request::Common;
7 use lib 't/lib';
8 use SGN::Test qw/ request /;
9 BEGIN { use_ok 'SGN::Controller::Project::Secretom::SecreTary' }
11 ok( request('/secretom/secretary')->is_success, 'Request should succeed' );
13 my $test_data = <<'';
14 >AT1G73440.1 AI22=4.545 Gravy22=-1.4545 nR=2 nS=10 nT=0 nDRQPEN=7 Nitrogen=28 Oxygen=42 
15 MARGESEGESSGSERESSSSSSGNESEPTKGTISKYEKQRLSRIAENKARLDALGISKAAKALLSPSPVSKKRRVKRNSGEEDDDYTPVIADGDGDEDDDEVEEIDEDEEFLCKRKNKSSASKRKVSSRKILNTSVSLGEDDDDLDKAIALSLQGSVAGSDKEAATMKKKRPELMSKTQMTQDELVMYFCQFDEGGKGFITLRDVAKMATVHDFTWTEEELQDMIRCFDMDKDGKLSLDEFRKIVSRCRMLKGS* 
16 >AT1G75120.1 AI22=119.545 Gravy22=0.5864 nR=2 nS=0 nT=0 nDRQPEN=6 Nitrogen=31 Oxygen=27 
17 MAVRKEKVQPFRECGIAIAVLVGIFIGCVCTILIPNDFVNFRSSKVASASCESPERVKMFKAEFAIISEKNGELRKQVSDLTEKVRLAEQKEVIKAGPFGTVTGLQTNPTVAPDESANPRLAKLLEKVAVNKEIIVVLANNNVKPMLEVQIASVKRVGIQNYLVVPLDDSLESFCKSNEVAYYKRDPDNAIDVVGKSRRSSDVSGLKFRVLREFLQLGYGVLLSDVDIVFLQNPFGHLYRDSDVESMSDGHDNNTAYGFNDVFDDPTMTRSRTVYTNRIWVFNSGFFYLRPTLPSIELLDRVTDTLSKSGGWDQAVFNQHLFYPSHPGYTGLYASKRVMDVYEFMNSRVLFKTVRKDEEMKKLKPVIIHMNYHSDKLERMQAAVEFYVNGKQDALDRFRDGS* 
18 >AT1G17600.1 AI22=61.818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20 >AT1G51380.1 AI22=84.091 Gravy22=-0.5318 nR=0 nS=0 nT=3 nDRQPEN=7 Nitrogen=26 Oxygen=36 
21 MEGTLDEENLVFETTKGIKPIKSFDDMGMNDKVLRGVYDYGYKKPSEIQQRALVPILKGRDVIAQAQSGTGKTSMIAISVCQIVNISSRKVQVLVLSPSRELASQTEKTIQAIGAHTNIQAHACIGGKSIGEDIKKLERGVHAVSGTPGRVYDMIKRGSLQTKAVKLLVLDESDEMLSKGLKDQIYDVYRALPHDIQVCLISATLPQEILEMTEKFMTDPVRILVKPDELTLEGIKQYYVDVDKEEWKFDTLCDLYGRLTINQAIIFCNTRQKVDWLTEKMRSSNFIVSSMHGDKRQKERDDIMNQFRSFKSRVLIASDVWARGIDVQTVSHVINYDIPNNPELYIHRIGRAGRFGREGVAINFVKSSDMKDLKDIERHYGTKIREMPADLV* 
22 >AT1G77370.1 AI22=159.091 Gravy22=1.3318 nR=2 nS=1 nT=0 nDRQPEN=6 Nitrogen=29 Oxygen=28 
23 MVDQSPRRVVVAALLLFVVLCDLSNSAGAANSVSAFVQNAILSNKIVIFSKSYCPYCLRSKRIFSQLKEEPFVVELDQREDGDQIQYELLEFVGRRTVPQVFVNGKHIGGSDDLGAALESGQLQKLLAAS* 
24 >AT1G44090.1 AI22=66.364 Gravy22=-0.0773 nR=2 nS=1 nT=2 nDRQPEN=6 Nitrogen=31 Oxygen=28 
25 MCIYASRQTVCPYLTPFKVKRPKSREMNSSDVNFSLLQSQPNVPAEFFWPEKDVAPSEGDLDLPIIDLSGFLNGNEAETQLAAKAVKKACMAHGTFLVVNHGFKSGLAEKALEISSLFFGLSKDEKLRAYRIPGNISGYTAGHSQRFSSNLPWNETLTLAFKKGPPHVVEDFLTSRLGNHRQEIGQVFQEFCDAMNGLVMDLMELLGISMGLKDRTYYRRFFEDGSGIFRCNYYPPCKQPEKALGVGPHNDPTAITVLLQDDVVGLEVFAAGSWQTVRPRPGALVVNVGDTFMALSNGNYRSCYHRAVVNKEKVRRSLVFFSCPREDKIIVPPPELVEGEEASRKYPDFTWAQLQKFTQSGYRVDNTTLHNFSSWLVSNSDKKST* 
27 my @test_requests = (
28     # simulate a pasted sequence with 
29     ( POST '/secretom/secretary/run', [ sequence => $test_data ] ),
31     # simulate an uploaded file
32     ( POST '/secretom/secretary/run',
33       Content_Type => 'form-data',
34       Content => [
35           sequence_file => [
36               undef,
37               'test.fasta',
38               Content_Type => 'application/octet-stream',
39               Content => $test_data,
40              ],
41          ],
42      ),
44     # simulate a pasted sequence with sort box checked
45     ( POST '/secretom/secretary/run', [ sequence => $test_data, sort => 'Sort by score' ] ),
47     # simulate both an uploaded file and a paste, both boxes checked
48     ( POST '/secretom/secretary/run',
49       Content_Type => 'form-data',
50       Content => [
51           sequence      => $test_data,
52           sequence_file => [
53               undef,
54               'test.fasta',
55               Content_Type => 'application/octet-stream',
56               Content => $test_data,
57              ],
58            sort => 1,
59          ],
60      ),
62    );
65 foreach my $test_req ( @test_requests ) {
66     my $response = request $test_req;
68     like( $response->content, qr/(2|4) secreted sequences predicted out of (6|12)/,
69           'got correct secreted sequence count' );
71     like( $response->content, qr/$_/, "ID $_ appears in output" )
72         for qw( AT1G73440.1  AT1G75120.1  AT1G17600.1  AT1G51380.1  AT1G77370.1 AT1G44090.1 );
74     like( $response->content, qr/$_\s+YES/, "$_ shows as secreted" )
75         for qw( AT1G77370.1  AT1G75120.1 );
77     like( $response->content, qr/$_\s+NO/, "$_ shows as NOT secreted" )
78         for qw( AT1G73440.1 AT1G17600.1  AT1G51380.1 AT1G44090.1 );
81 done_testing;