Example #1
0
 def test_gen_url_version(self):
     self.assertEqual(ns.gen_url("nation", "test", version="7"), "https://www.nationstates.net/cgi-bin/api.cgi?nation=test&v=7")
from nationstates import gen_url
from nationstates import Shard

# https://www.nationstates.net/cgi-bin/api.cgi?nation=the_united_island_tribes&q=name+fullname
print(gen_url("nation", "The United Island Tribes", shard=["name", "fullname"]))

#You also can use shard objects to add shards with additional arguments.
#Note: This only works in 1.1.34.64+, in older versions mode must be a string.
#https://www.nationstates.net/cgi-bin/api.cgi?nation=the_united_island_tribes&q=census&mode=score+rank+prank
print(gen_url("nation", "The United Island Tribes", shard=[Shard("census", mode=["score", "rank", "prank"])]))

#Some shards have arguments that invade on pythons syntax, for these you can get around them by using **{}
#https://www.nationstates.net/cgi-bin/api.cgi?nation=the_united_island_tribes&q=tgcanrecruit&from=The+Rejected+Realms
print(gen_url("nation", "The United Island Tribes", shard=[Shard("tgcanrecruit", **{"from": "The Rejected Realms"})]))
Example #3
0
 def test_gen_url_shard_args(self):
     self.assertEqual(ns.gen_url("nation", "test", shard=[Shard("test", test="test")]), "https://www.nationstates.net/cgi-bin/api.cgi?nation=test&q=test&test=test")
Example #4
0
 def test_gen_url(self):
     self.assertEqual(ns.gen_url("nation", "TEST"), "https://www.nationstates.net/cgi-bin/api.cgi?nation=test")
Example #5
0
 def test_gen_url_version(self):
     self.assertIsInstance(ns.gen_url("nation", "test", version="7"), str)
Example #6
0
 def test_gen_url_shard(self):
     self.assertIsInstance(ns.gen_url("nation", "test", shard=["test"]), str)
Example #7
0
 def test_gen_url(self): 
     self.assertIsInstance(ns.gen_url("nation", "TEST"), str)