-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
65 lines (44 loc) · 1.93 KB
/
test.py
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
from gw2lib.common import genItemChatCode
from gw2lib.mumble import GW2MumbleData
from gw2lib.webapi import SimpleClient, API_CACHE
def test_api():
"""
Simple Web API test
"""
API_CACHE.load() # Not needed, but with it module can reuse cache between runs
api2 = SimpleClient("v2") # Using version 2 of the api
api1 = SimpleClient() # Uses version 1 of the api by default
item = 12452 # Omnomberry Bar
# Get chatcode for 25 omnomberry bars
print("25", api2.items(item).name, "has Chatcode:", genItemChatCode(item, 25))
print(api2.items(item).name, "is used in recepies:")
for recipe_id in api2.recipes.search(input=item):
item_id = api2.recipes(recipe_id).output_item_id
print(" *", api2.items(item_id).name, "[%s]" % api2.items(item_id).type)
guild = "Nectarines"
print("\n%s Guild tag:" % guild, api1.guild_details(guild_name=guild).tag)
print("%s Guild ID :" % guild, api1("guild_details", guild_name=guild).guild_id) # Alternative access
print("\nHelp url for api2.items() is", api2.items.get_help_url())
# Return a dictionary instead of a generic object
print(api2.dict().items(item))
# Use an iterable as argument
print(api2.items(ids=[46731, 50065]))
API_CACHE.save() # Not needed, but with it module can reuse cache between runs
def test_mumble():
"""
Simple Mumble API test
"""
m = GW2MumbleData()
m.update()
# Player identity data
print("Identity", m.identity)
# Extra data, including map info and client's position and looking direction
print("Extra", m.extra)
print("Player direction X is", m.extra.player_direction.x) # x, y, z
# Listing of various set fields in mumble structure
for x in ["name", "context", "identity", "description", "uiVersion", "uiTick"]:
print(" *", x, ":", getattr(m.data, x))
print("Testing mumble link\n")
test_mumble()
print("\nTesting API\n")
test_api()