pwood-wowr 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +41 -0
- data/VERSION.yml +4 -0
- data/lib/wowr.rb +1253 -0
- data/lib/wowr/achievements.rb +143 -0
- data/lib/wowr/arena_team.rb +80 -0
- data/lib/wowr/calendar.rb +78 -0
- data/lib/wowr/character.rb +832 -0
- data/lib/wowr/dungeon.rb +85 -0
- data/lib/wowr/exceptions.rb +163 -0
- data/lib/wowr/extensions.rb +67 -0
- data/lib/wowr/general.rb +39 -0
- data/lib/wowr/guild.rb +85 -0
- data/lib/wowr/guild_bank.rb +188 -0
- data/lib/wowr/item.rb +577 -0
- data/test/wowr_arena_team_test.rb +41 -0
- data/test/wowr_character_test.rb +88 -0
- data/test/wowr_dungeon_test.rb +63 -0
- data/test/wowr_guild_test.rb +27 -0
- data/test/wowr_item_test.rb +8 -0
- data/test/wowr_test.rb +456 -0
- data/test/xml/arena_team_search.xml +60 -0
- data/test/xml/arena_team_single.xml +25 -0
- data/test/xml/armory-search.xml +207 -0
- data/test/xml/armory_search.xml +126 -0
- data/test/xml/benedictt.xml +152 -0
- data/test/xml/character-reputation.xml +82 -0
- data/test/xml/character-sheet.xml +145 -0
- data/test/xml/character-skills.xml +60 -0
- data/test/xml/character-talents.xml +29 -0
- data/test/xml/character_info.xml +141 -0
- data/test/xml/character_search.xml +102 -0
- data/test/xml/dungeonStrings.xml +550 -0
- data/test/xml/dungeons.xml +1658 -0
- data/test/xml/example.xml +127 -0
- data/test/xml/guild-info.xml +302 -0
- data/test/xml/item-info.xml +20 -0
- data/test/xml/item-tooltip.xml +167 -0
- data/test/xml/itemSearch.xml +46 -0
- data/test/xml/item_search.xml +63 -0
- metadata +96 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'wowr_test.rb'
|
5
|
+
|
6
|
+
class WowrDungeonTest < WowrTest
|
7
|
+
def test_get_arena_team
|
8
|
+
arena_team_name = 'cake'
|
9
|
+
|
10
|
+
assert_raises Wowr::Exceptions::RealmNotSet do
|
11
|
+
@api_empty.get_arena_team(:team_name => arena_team_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
assert_raises Wowr::Exceptions::ArenaTeamNameNotSet do
|
15
|
+
@api_empty.get_arena_team(:realm => "Cake")
|
16
|
+
end
|
17
|
+
|
18
|
+
assert_raises Wowr::Exceptions::ArenaTeamNameNotSet do
|
19
|
+
@api_empty.get_arena_team("", 5)
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_raises Wowr::Exceptions::InvalidArenaTeamSize do
|
23
|
+
@api_empty.get_arena_team(arena_team_name, :realm => "cake")
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_raises Wowr::Exceptions::InvalidArenaTeamSize do
|
27
|
+
@api_empty.get_arena_team(arena_team_name, 9, :realm => "cake")
|
28
|
+
end
|
29
|
+
|
30
|
+
no_team = Wowr::API.new(:realm => "Barthilas")
|
31
|
+
assert_raises Wowr::Exceptions::ArenaTeamNotFound do
|
32
|
+
no_team.get_arena_team(arena_team_name, 5)
|
33
|
+
end
|
34
|
+
|
35
|
+
defaults_api = Wowr::API.new(:character_name => "cake", :realm => "Terenas")
|
36
|
+
assert_not_nil defaults_api.get_arena_team(arena_team_name, 5, :realm => "Terenas")
|
37
|
+
assert_not_nil defaults_api.get_arena_team(arena_team_name, 5)
|
38
|
+
assert_not_nil defaults_api.get_arena_team(arena_team_name, :team_size => 5)
|
39
|
+
assert_not_nil defaults_api.get_arena_team(:team_name => arena_team_name, :team_size => 5)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'wowr_test.rb'
|
5
|
+
|
6
|
+
class WowrCharacterTest < WowrTest
|
7
|
+
def test_character_contents
|
8
|
+
|
9
|
+
# Reve::API.cakes = XML_BASE + '.xml'
|
10
|
+
character = nil
|
11
|
+
assert_nothing_raised do
|
12
|
+
character = @api_set.get_character
|
13
|
+
end
|
14
|
+
|
15
|
+
assert_instance_of Wowr::Classes::FullCharacter, character
|
16
|
+
|
17
|
+
assert_not_nil character.name
|
18
|
+
assert_not_nil character.level
|
19
|
+
assert_not_nil character.char_url
|
20
|
+
|
21
|
+
assert_not_nil character.klass
|
22
|
+
assert_not_nil character.klass_id
|
23
|
+
|
24
|
+
assert_not_nil character.gender
|
25
|
+
assert_not_nil character.gender_id
|
26
|
+
|
27
|
+
assert_not_nil character.race
|
28
|
+
assert_not_nil character.race_id
|
29
|
+
|
30
|
+
assert_not_nil character.faction
|
31
|
+
assert_not_nil character.faction_id
|
32
|
+
|
33
|
+
# If these are empty, they're returned as nil
|
34
|
+
# assert_not_nil character.guild
|
35
|
+
# assert_not_nil character.guild_url
|
36
|
+
# assert_not_nil character.prefix
|
37
|
+
# assert_not_nil character.suffix
|
38
|
+
|
39
|
+
assert_not_nil character.realm
|
40
|
+
|
41
|
+
# This could be nil too
|
42
|
+
assert_not_nil character.battle_group
|
43
|
+
|
44
|
+
# assert_not_nil character.last_modified
|
45
|
+
|
46
|
+
assert_instance_of Wowr::Classes::Agility, character.agi
|
47
|
+
assert_instance_of Wowr::Classes::Agility, character.agility
|
48
|
+
|
49
|
+
# assert_equals character.agi.base, character.agility.base
|
50
|
+
# assert_equals character.agi.armor, character.agility.armor
|
51
|
+
|
52
|
+
character.arena_teams do |arena_team|
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_character_exceptions
|
60
|
+
no_data_api = Wowr::API.new
|
61
|
+
only_realm_api = Wowr::API.new(:realm => "Stormrage")
|
62
|
+
defaults_api = Wowr::API.new(:character_name => "cake", :realm => "Barthilas")
|
63
|
+
|
64
|
+
assert_raises Wowr::Exceptions::CharacterNameNotSet do
|
65
|
+
no_data_api.get_character
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_raises Wowr::Exceptions::CharacterNameNotSet do
|
69
|
+
only_realm_api.get_character
|
70
|
+
end
|
71
|
+
|
72
|
+
assert_raises Wowr::Exceptions::RealmNotSet do
|
73
|
+
no_data_api.get_character("Phog")
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_nothing_raised do
|
77
|
+
defaults_api.get_character
|
78
|
+
only_realm_api.get_character("Phog")
|
79
|
+
end
|
80
|
+
|
81
|
+
assert_nothing_raised do
|
82
|
+
defaults_api.get_character_sheet
|
83
|
+
only_realm_api.get_character_sheet("Phog")
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'wowr_test.rb'
|
5
|
+
|
6
|
+
class WowrDungeonTest < WowrTest
|
7
|
+
|
8
|
+
def test_dungeons
|
9
|
+
dungeons = @api_no_cache.get_dungeons
|
10
|
+
|
11
|
+
assert_equal dungeons["botanica"], dungeons[3847]
|
12
|
+
|
13
|
+
dungeons.values.uniq.each do |dungeon|
|
14
|
+
test_dungeon(dungeon)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_dungeon(dungeon)
|
19
|
+
# at least one should be set
|
20
|
+
if (!dungeon.key)
|
21
|
+
assert_not_nil dungeon.id
|
22
|
+
else
|
23
|
+
assert_not_nil dungeon.key
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_kind_of Integer, dungeon.level_minimum
|
27
|
+
assert_kind_of Integer, dungeon.level_maximum
|
28
|
+
|
29
|
+
assert_not_nil dungeon.level_minimum
|
30
|
+
assert_not_nil dungeon.level_maximum
|
31
|
+
|
32
|
+
assert_equal dungeon.level_minimum, dungeon.min_level
|
33
|
+
assert_equal dungeon.level_maximum, dungeon.max_level
|
34
|
+
|
35
|
+
assert_kind_of Integer, dungeon.party_size
|
36
|
+
assert_not_nil dungeon.party_size
|
37
|
+
|
38
|
+
# assert_kind_of Boolean, dungeon.raid
|
39
|
+
assert_not_nil dungeon.raid
|
40
|
+
|
41
|
+
assert_not_nil dungeon.release
|
42
|
+
|
43
|
+
# assert_kind_of FalseClass || TrueClass, dungeon.heroic
|
44
|
+
assert_not_nil dungeon.heroic
|
45
|
+
|
46
|
+
assert_equal dungeon.bosses["commandersarannis"], dungeon.bosses[3847]
|
47
|
+
assert_equal dungeon.bosses["highbotanistfreywinn"], dungeon.bosses[17975]
|
48
|
+
|
49
|
+
dungeon.bosses.values.uniq.each do |boss|
|
50
|
+
test_boss(boss)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_boss(boss)
|
55
|
+
if (!boss.key)
|
56
|
+
assert_not_nil boss.id
|
57
|
+
else
|
58
|
+
assert_not_nil boss.key
|
59
|
+
end
|
60
|
+
assert_not_nil boss.type
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'wowr_test.rb'
|
5
|
+
|
6
|
+
class WowrGuildTest < WowrTest
|
7
|
+
def test_guild
|
8
|
+
assert_not_nil @api_set.get_guild
|
9
|
+
assert_not_nil @api_set.get_guild("cake")
|
10
|
+
assert_not_nil @api_set.get_guild("Moo", :realm => "Black Dragonflight")
|
11
|
+
assert_not_nil @api_set.get_guild(:guild_name => "Moo", :realm => "Black Dragonflight")
|
12
|
+
|
13
|
+
assert_raises Wowr::Exceptions::GuildNameNotSet do
|
14
|
+
@api_empty.get_guild
|
15
|
+
end
|
16
|
+
|
17
|
+
assert_raises Wowr::Exceptions::RealmNotSet do
|
18
|
+
@api_empty.get_guild("cake")
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_not_nil @api_empty.get_guild("Moo", :realm => "Black Dragonflight")
|
22
|
+
assert_not_nil @api_empty.get_guild(:guild_name => "Moo", :realm => "Black Dragonflight")
|
23
|
+
|
24
|
+
assert_instance_of Wowr::Classes::FullGuild, @api_empty.get_guild("Moo", :realm => "Black Dragonflight")
|
25
|
+
assert_instance_of Wowr::Classes::SearchGuild, @api_empty.search_guilds("Moo").first
|
26
|
+
end
|
27
|
+
end
|
data/test/wowr_test.rb
ADDED
@@ -0,0 +1,456 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require '../lib/wowr.rb'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
|
6
|
+
XML_BASE = File.join(File.dirname(__FILE__) + '/xml/')
|
7
|
+
SAVE_PATH = File.join(File.dirname(__FILE__),'downloads')
|
8
|
+
|
9
|
+
module Wowr
|
10
|
+
class API
|
11
|
+
|
12
|
+
@@cache_directory_path = 'test_cache/'
|
13
|
+
|
14
|
+
# def get_xml(url, opts = {})
|
15
|
+
# response = File.open(url,'r')
|
16
|
+
# begin
|
17
|
+
# doc = Hpricot.XML(response)
|
18
|
+
# # xml = check_exception(response)
|
19
|
+
# # ret = []
|
20
|
+
# # return xml if just_xml
|
21
|
+
# # xml.search("//rowset/row").each do |elem|
|
22
|
+
# # ret << klass.new(elem)
|
23
|
+
# # end
|
24
|
+
# # ret
|
25
|
+
# ensure
|
26
|
+
# response.close
|
27
|
+
#
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# def process_query(klass,url,just_xml,args = {})
|
32
|
+
# response = File.open(url,'r')
|
33
|
+
# @last_hash = compute_hash(args.merge({:url => url, :just_hash => true })) # compute hash
|
34
|
+
# begin
|
35
|
+
# xml = check_exception(response)
|
36
|
+
# ret = []
|
37
|
+
# return xml if just_xml
|
38
|
+
# xml.search("//rowset/row").each do |elem|
|
39
|
+
# ret << klass.new(elem)
|
40
|
+
# end
|
41
|
+
# ret
|
42
|
+
# ensure
|
43
|
+
# response.close
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
class WowrTest < Test::Unit::TestCase
|
51
|
+
|
52
|
+
def setup
|
53
|
+
@api_empty = Wowr::API.new
|
54
|
+
@api_set = Wowr::API.new(:character_name => 'Clublife', :realm => "Barthilas", :guild_name => "Cake")
|
55
|
+
@api_no_cache = Wowr::API.new(:caching => false)
|
56
|
+
end
|
57
|
+
|
58
|
+
def teardown
|
59
|
+
@api_set.clear_cache
|
60
|
+
FileUtils.rm_rf(SAVE_PATH)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_api_defaults
|
64
|
+
assert_nil @api_empty.character_name
|
65
|
+
assert_nil @api_empty.guild_name
|
66
|
+
assert_nil @api_empty.realm
|
67
|
+
|
68
|
+
assert_equal @api_empty.locale, 'us'
|
69
|
+
assert_equal @api_empty.lang, 'default'
|
70
|
+
assert_equal @api_empty.caching, true
|
71
|
+
assert_equal @api_empty.cache_timeout, (7*24*60*60)
|
72
|
+
assert_equal @api_empty.debug, false
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_api_constants
|
76
|
+
assert_equal Wowr::API.armory_base_url, 'wowarmory.com/'
|
77
|
+
|
78
|
+
assert_equal Wowr::API.search_url, 'search.xml'
|
79
|
+
|
80
|
+
assert_equal Wowr::API.character_sheet_url, 'character-sheet.xml'
|
81
|
+
assert_equal Wowr::API.character_talents_url, 'character-talents.xml'
|
82
|
+
assert_equal Wowr::API.character_reputation_url, 'character-reputation.xml'
|
83
|
+
|
84
|
+
assert_equal Wowr::API.guild_info_url, 'guild-info.xml'
|
85
|
+
|
86
|
+
assert_equal Wowr::API.item_info_url, 'item-info.xml'
|
87
|
+
assert_equal Wowr::API.item_tooltip_url, 'item-tooltip.xml'
|
88
|
+
|
89
|
+
assert_equal Wowr::API.arena_team_url, 'team-info.xml'
|
90
|
+
|
91
|
+
assert_equal Wowr::API.guild_bank_contents_url, 'vault/guild-bank-contents.xml'
|
92
|
+
assert_equal Wowr::API.guild_bank_log_url, 'vault/guild-bank-log.xml'
|
93
|
+
|
94
|
+
assert_equal Wowr::API.login_url, 'login/login.xml'
|
95
|
+
|
96
|
+
assert_equal Wowr::API.max_connection_tries, 10
|
97
|
+
|
98
|
+
assert_equal Wowr::API.cache_directory_path, 'test_cache/'
|
99
|
+
|
100
|
+
assert_equal Wowr::API.default_cache_timeout, (7*24*60*60)
|
101
|
+
assert_equal Wowr::API.failed_cache_timeout, (60*60*24)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_api_params
|
105
|
+
api = Wowr::API.new(:character_name => 'foo',
|
106
|
+
:guild_name => 'bar',
|
107
|
+
:realm => 'baz',
|
108
|
+
:locale => 'hoge',
|
109
|
+
:lang => 'hogehoge',
|
110
|
+
:caching => false,
|
111
|
+
:debug => true)
|
112
|
+
|
113
|
+
assert_equal api.character_name, 'foo'
|
114
|
+
assert_equal api.guild_name, 'bar'
|
115
|
+
assert_equal api.realm, 'baz'
|
116
|
+
assert_equal api.locale, 'hoge'
|
117
|
+
assert_equal api.lang, 'hogehoge'
|
118
|
+
assert_equal api.caching, false
|
119
|
+
assert_equal api.debug, true
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_no_server
|
123
|
+
api = Wowr::API.new(:locale => 'hoge')
|
124
|
+
|
125
|
+
assert_raises Wowr::Exceptions::ServerDoesNotExist do
|
126
|
+
api.search_characters(:search => 'cake')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_no_item
|
131
|
+
assert_raises Wowr::Exceptions::ItemNotFound do
|
132
|
+
@api_empty.get_item_info(:item_id => 9999999)
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_raises Wowr::Exceptions::ItemNotFound do
|
136
|
+
@api_empty.get_item_info(9999999)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_blah
|
141
|
+
item_id = 24032
|
142
|
+
options = {:lang => 'fr_fr'}
|
143
|
+
y1 = @api_empty.get_item_tooltip(item_id)
|
144
|
+
y2 = @api_empty.get_item_tooltip(:item_id => item_id, :lang => 'fr_fr')
|
145
|
+
y3 = @api_empty.get_item_tooltip(item_id, {:lang => 'fr_fr'})
|
146
|
+
y4 = @api_empty.get_item_tooltip(item_id, options)
|
147
|
+
|
148
|
+
# assert_equal y1, y2
|
149
|
+
# assert_equal y2, y3
|
150
|
+
# assert_equal y3, y4
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_searching
|
154
|
+
assert_not_nil @api_empty.search_characters("cake")
|
155
|
+
assert_not_nil @api_empty.search_items("cake")
|
156
|
+
assert_not_nil @api_empty.search_guilds("cake")
|
157
|
+
assert_not_nil @api_empty.search_arena_teams("cake")
|
158
|
+
|
159
|
+
# Some results found
|
160
|
+
assert_not_equal @api_empty.search_characters("cake"), []
|
161
|
+
assert_not_equal @api_empty.search_items("cake"), []
|
162
|
+
assert_not_equal @api_empty.search_guilds("cake"), []
|
163
|
+
assert_not_equal @api_empty.search_arena_teams("cake"), []
|
164
|
+
|
165
|
+
assert_raises Wowr::Exceptions::NoSearchString do
|
166
|
+
@api_empty.search("")
|
167
|
+
end
|
168
|
+
|
169
|
+
assert_raises Wowr::Exceptions::InvalidSearchType do
|
170
|
+
@api_empty.search("Hi")
|
171
|
+
end
|
172
|
+
|
173
|
+
assert_raises Wowr::Exceptions::InvalidSearchType do
|
174
|
+
@api_empty.search("Hi", :type => 'cakes')
|
175
|
+
end
|
176
|
+
|
177
|
+
assert_raises ArgumentError do
|
178
|
+
@api_empty.search_characters
|
179
|
+
end
|
180
|
+
|
181
|
+
assert_raises ArgumentError do
|
182
|
+
@api_empty.search_items
|
183
|
+
end
|
184
|
+
|
185
|
+
assert_raises ArgumentError do
|
186
|
+
@api_empty.search_guilds
|
187
|
+
end
|
188
|
+
|
189
|
+
assert_raises ArgumentError do
|
190
|
+
@api_empty.search_arena_teams
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
# def test_character
|
198
|
+
#
|
199
|
+
# char = defaults_api.get_character_sheet
|
200
|
+
#
|
201
|
+
# assert_not_nil char
|
202
|
+
#
|
203
|
+
# assert_equals char, defaults_api.get_character_sheet("cake")
|
204
|
+
#
|
205
|
+
# assert_not_nil defaults_api.get_character_sheet("cake")
|
206
|
+
# assert_not_nil defaults_api.get_character_sheet("Phog")
|
207
|
+
#
|
208
|
+
# phog = assert_not_nil defaults_api.get_character_sheet("Phog")
|
209
|
+
#
|
210
|
+
# defaults_api.get_character_sheet("Phog", :realm => "Stormrage")
|
211
|
+
#
|
212
|
+
# api2.get_character_sheet("Phog") # should be ok
|
213
|
+
# api.get_character_sheet("cake", :realm => "Barthilas")
|
214
|
+
# api2.get_character_sheet("cake", :realm => "Barthilas")
|
215
|
+
# api.get_character_sheet(:character_name => "cake", :realm => "Barthilas")
|
216
|
+
# api2.get_character_sheet(:character_name => "cake", :realm => "Barthilas")
|
217
|
+
# end
|
218
|
+
#
|
219
|
+
#
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
# ensure that the requested language is being returned
|
224
|
+
def test_languages
|
225
|
+
language = 'fr_fr'
|
226
|
+
api = Wowr::API.new(:lang => language)
|
227
|
+
|
228
|
+
returned_language = 'fr_fr'
|
229
|
+
|
230
|
+
assert_equal language, returned_language
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_caching
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
# def test_bad_xml
|
240
|
+
# Wowr::API.character_sheet_url = XML_BASE + 'bad_character.xml'
|
241
|
+
# skill = @api.skill_in_training
|
242
|
+
# assert_not_nil @api.last_hash
|
243
|
+
# end
|
244
|
+
#
|
245
|
+
# def test_item
|
246
|
+
#
|
247
|
+
# end
|
248
|
+
#
|
249
|
+
|
250
|
+
|
251
|
+
def test_item
|
252
|
+
item = @api_empty.get_item_info(4336)
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
def test_item_api_references
|
257
|
+
|
258
|
+
end
|
259
|
+
#
|
260
|
+
#
|
261
|
+
# def test_character_sheet
|
262
|
+
# Wowr::API.character_sheet_url = XML_BASE + 'character-sheet.xml'
|
263
|
+
# #Reve::API.conqurable_outposts_url = XML_BASE + 'conqurable_stations.xml'
|
264
|
+
# character = nil
|
265
|
+
# assert_nothing_raised do
|
266
|
+
# character = @api.get_character_sheet
|
267
|
+
# end
|
268
|
+
#
|
269
|
+
# assert_not_nil character.title
|
270
|
+
# assert_not_nil character.health
|
271
|
+
#
|
272
|
+
# test_second_bar(character.second_bar)
|
273
|
+
#
|
274
|
+
# assert_instance_of Wowr::Classes::Strength, character.strength
|
275
|
+
#
|
276
|
+
# test_strength(character.strength)
|
277
|
+
# test_agility(character.agility)
|
278
|
+
# test_stamina(character.stamina)
|
279
|
+
# test_intellect(character.intellect)
|
280
|
+
# test_spirit(character.spirit)
|
281
|
+
#
|
282
|
+
# test_melee(character.melee)
|
283
|
+
# test_ranged(character.ranged)
|
284
|
+
# test_spell(character.spell)
|
285
|
+
# test_defenses(character.defenses)
|
286
|
+
#
|
287
|
+
# character.professions do |prof|
|
288
|
+
# test_professions(prof)
|
289
|
+
# end
|
290
|
+
#
|
291
|
+
# character.items do |item|
|
292
|
+
# test_equipped_item(item)
|
293
|
+
# end
|
294
|
+
#
|
295
|
+
# character.buffs do |buff|
|
296
|
+
# test_buffs_debuffs(buff)
|
297
|
+
# end
|
298
|
+
#
|
299
|
+
# character.debuffs do |debuff|
|
300
|
+
# test_buffs_debuffs(debuff)
|
301
|
+
# end
|
302
|
+
# end
|
303
|
+
#
|
304
|
+
# def test_second_bar
|
305
|
+
#
|
306
|
+
# end
|
307
|
+
#
|
308
|
+
# def test_strength(strength)
|
309
|
+
# attrs = ["base", "effective", "attack", "block"]
|
310
|
+
#
|
311
|
+
# attrs do |att|
|
312
|
+
# assert_not_nil strength.att
|
313
|
+
# end
|
314
|
+
# end
|
315
|
+
#
|
316
|
+
# def test_agility
|
317
|
+
#
|
318
|
+
# end
|
319
|
+
#
|
320
|
+
# def test_stamina
|
321
|
+
#
|
322
|
+
# end
|
323
|
+
#
|
324
|
+
# def test_intellect
|
325
|
+
#
|
326
|
+
# end
|
327
|
+
#
|
328
|
+
# def test_spirit
|
329
|
+
#
|
330
|
+
# end
|
331
|
+
#
|
332
|
+
# def test_melee
|
333
|
+
#
|
334
|
+
# end
|
335
|
+
#
|
336
|
+
# def test_ranged
|
337
|
+
#
|
338
|
+
# end
|
339
|
+
#
|
340
|
+
# def test_spell
|
341
|
+
#
|
342
|
+
# end
|
343
|
+
#
|
344
|
+
# def test_defenses
|
345
|
+
#
|
346
|
+
# end
|
347
|
+
#
|
348
|
+
# def test_profession
|
349
|
+
#
|
350
|
+
# end
|
351
|
+
#
|
352
|
+
# def test_equipped_item
|
353
|
+
#
|
354
|
+
# end
|
355
|
+
# # # TODO: Massive problem, doesn't fill in resistances for some reason
|
356
|
+
# # resist_types = ['arcane', 'fire', 'frost', 'holy', 'nature', 'shadow']
|
357
|
+
# # @resistances = {}
|
358
|
+
# # resist_types.each do |res|
|
359
|
+
# # @resistances[res] = Resistance.new(elem%'resistances'%res)
|
360
|
+
# # end
|
361
|
+
# #
|
362
|
+
# # @talent_spec = TalentSpec.new(elem%'talentSpec')
|
363
|
+
# #
|
364
|
+
# # @pvp = Pvp.new(elem%'pvp')
|
365
|
+
#
|
366
|
+
#
|
367
|
+
# def test_buffs_debuffs
|
368
|
+
#
|
369
|
+
# end
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
# def test_skill_tree_clean
|
374
|
+
# Reve::API.skill_tree_url = XML_BASE + 'skilltree.xml'
|
375
|
+
# skilltrees = nil
|
376
|
+
# assert_nothing_raised do
|
377
|
+
# skilltrees = @api.skill_tree
|
378
|
+
# end
|
379
|
+
# assert_not_nil @api.last_hash
|
380
|
+
# assert_not_nil @api.cached_until
|
381
|
+
# assert_equal 2, skilltrees.size
|
382
|
+
# skilltrees.each do |skill|
|
383
|
+
# assert_not_nil skill.type_id
|
384
|
+
# assert_not_nil skill.name
|
385
|
+
# assert_not_nil skill.rank
|
386
|
+
# assert_not_nil skill.description
|
387
|
+
# skill.bonuses.each do |bonus|
|
388
|
+
# assert_kind_of Reve::Classes::SkillBonus, bonus
|
389
|
+
# end
|
390
|
+
# skill.attribs.each do |attrib|
|
391
|
+
# assert_kind_of Reve::Classes::RequiredAttribute, attrib
|
392
|
+
# end
|
393
|
+
# skill.required_skills.each do |req|
|
394
|
+
# assert_kind_of Reve::Classes::SkillRequirement, req
|
395
|
+
# end
|
396
|
+
# end
|
397
|
+
# end
|
398
|
+
#
|
399
|
+
def test_cache_timeout
|
400
|
+
api = Wowr::API.new(:character_name => 'Cake', :realm => "Barthilas", :guild_name => "Cake", :debug => true, :caching => true)
|
401
|
+
# api = Wowr::API.new(:character_name => 'Sonny', :realm => "Arena Tournament 1", :locale => 'eu', :debug => true, :caching => false)
|
402
|
+
# api = Wowr::API.new(:realm => "Trollbane", :guild_name => "Rawr", :locale => 'eu', :debug => true, :caching => true)
|
403
|
+
# api.default_cache_timeout = 10
|
404
|
+
|
405
|
+
# char = api.get_character
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
# path defaults_api.cache_path(url)
|
411
|
+
#
|
412
|
+
# if File.exists?(path) ||
|
413
|
+
# options[:refresh_cache] ||
|
414
|
+
# (File.mtime(path) < Time.now - @cache_timeout)
|
415
|
+
|
416
|
+
|
417
|
+
end
|
418
|
+
|
419
|
+
def test_money
|
420
|
+
no_gold_silver = Wowr::Classes::Money.new(43)
|
421
|
+
assert_equal no_gold_silver.gold, 0
|
422
|
+
assert_equal no_gold_silver.silver, 0
|
423
|
+
assert_equal no_gold_silver.bronze, 43
|
424
|
+
assert_equal no_gold_silver.total, 43
|
425
|
+
|
426
|
+
money = Wowr::Classes::Money.new(5552243)
|
427
|
+
assert_equal money.gold, 555
|
428
|
+
assert_equal money.silver, 22
|
429
|
+
assert_equal money.bronze, 43
|
430
|
+
assert_equal money.total, 5552243
|
431
|
+
|
432
|
+
assert_equal (money + no_gold_silver).total, 5552286
|
433
|
+
assert_equal (money - no_gold_silver).total, 5552200
|
434
|
+
end
|
435
|
+
|
436
|
+
|
437
|
+
def test_assignment
|
438
|
+
assert_nothing_raised do
|
439
|
+
temp = Wowr::API.search_url
|
440
|
+
Wowr::API.search_url = "test"
|
441
|
+
Wowr::API.search_url = temp
|
442
|
+
|
443
|
+
temp = Wowr::API.cache_directory_path
|
444
|
+
Wowr::API.cache_directory_path = "hello/"
|
445
|
+
Wowr::API.cache_directory_path = temp
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
end
|
450
|
+
|
451
|
+
|
452
|
+
# require 'wowr_character_test.rb'
|
453
|
+
# require 'wowr_guild_test.rb'
|
454
|
+
# require 'wowr_item_test.rb'
|
455
|
+
# require 'wowr_arena_team_test.rb'
|
456
|
+
# require 'wowr_dungeon_test.rb'
|