/
test-togows-rest-template.erb
130 lines (98 loc) · 3.96 KB
/
test-togows-rest-template.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
require 'open-uri'
require 'test/unit'
require 'test-helper'
class TogoWSSearch<%= TNAMESPACE %>Test < Test::Unit::TestCase
def test_<%= tnamespace.sub("-","_") %>
assert_404 'http://togows.dbcls.jp/search/<%= tnamespace %>'
end
def test_query
assert_200 'http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>'
end
def test_count
@r = open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/count')
assert_equal('200', @r.status.first)
assert(7 <= @r.read.to_i)
end
def test_offset_limit
@r = open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/10,10')
assert_equal('200', @r.status.first)
assert_equal(10, @r.read.split("\n").size)
end
def test_offset_limit_100
@r = open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/10,100')
assert_equal('200', @r.status.first)
assert_equal(100, @r.read.split("\n").size)
end
def test_the_last_without_n
@r = open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/10,10')
assert_equal('200', @r.status.first)
assert_equal(nil, @r.read =~ /\n$/)
end
def test_offset_limit_2
@r10 = open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/1,5').read.split("\n")
@r = [open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/1,1').read,
open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/2,1').read,
open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/3,1').read,
open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/4,1').read,
open('http://togows.dbcls.jp/search/<%= tnamespace %>/<%= TSearchQuery %>/5,1').read]
assert_equal(@r10, @r)
end
end
class TogoWSEntry<%= TNAMESPACE %>Test < Test::Unit::TestCase
def test_fields
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>?fields'
end
def test_fields_list
list = ['definition', 'entry_id', 'seq']
assert_list(list, 'http://togows.dbcls.jp/entry/<%= tnamespace %>?fields')
end
def test_formats
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>?formats'
end
def test_formats_list
list = ['fasta', 'gff', 'json', 'xml']
assert_list(list, 'http://togows.dbcls.jp/entry/<%= tnamespace %>?formats')
end
def test_not_found
assert_404 'http://togows.dbcls.jp/entry/<%= tnamespace %>/not_found'
end
def test_field_bad_request
assert_400 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/bad_request'
end
def test_format_bad_request
assert_400 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>.bad_request'
end
def test_<%= tnamespace.sub("-", '_') %>
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>'
end
def test_in_fasta
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>.fasta'
end
def test_in_json
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>.json'
end
def test_in_gff
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>.gff'
end
def test_in_xml
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>.xml'
end
def test__entry_id
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/entry_id'
end
def test__entry_id_in_json
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/entry_id.json'
end
def test_definition
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/definition'
end
def test_definition
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/definition.json'
end
def test__seq
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/seq'
end
def test_seq_in_json
assert_200 'http://togows.dbcls.jp/entry/<%= tnamespace %>/<%= TEntryID %>/seq.json'
end
end