Add testcase for partially populated config files
This commit is contained in:
parent
5a0065a873
commit
ade2fac3cb
1 changed files with 12 additions and 2 deletions
|
@ -31,6 +31,7 @@ class TestAuth(unittest.TestCase):
|
||||||
def create_config(config_file, host):
|
def create_config(config_file, host):
|
||||||
"""Create a dummy config file"""
|
"""Create a dummy config file"""
|
||||||
with open(os.path.join(CONFIG_PATH, config_file), "w") as conf:
|
with open(os.path.join(CONFIG_PATH, config_file), "w") as conf:
|
||||||
|
if host is not None:
|
||||||
conf.write("host = %s\n" % host)
|
conf.write("host = %s\n" % host)
|
||||||
conf.write("# Comment\n\n")
|
conf.write("# Comment\n\n")
|
||||||
conf.write("consumerKey = \"%s_consumer_key\"\n" % config_file)
|
conf.write("consumerKey = \"%s_consumer_key\"\n" % config_file)
|
||||||
|
@ -97,4 +98,13 @@ class TestAuth(unittest.TestCase):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
Trovebox(config_file="custom", host="host_override")
|
Trovebox(config_file="custom", host="host_override")
|
||||||
|
|
||||||
|
def test_partial_config_file(self):
|
||||||
|
""" Test that an incomplete config file causes default values to be set """
|
||||||
|
self.create_config("incomplete", host=None) # Don't write the host line
|
||||||
|
client = Trovebox(config_file="incomplete")
|
||||||
|
auth = client.auth
|
||||||
|
self.assertEqual(auth.host, "localhost")
|
||||||
|
self.assertEqual(auth.consumer_key, "incomplete_consumer_key")
|
||||||
|
self.assertEqual(auth.consumer_secret, "incomplete_consumer_secret")
|
||||||
|
self.assertEqual(auth.token, "incomplete_token")
|
||||||
|
self.assertEqual(auth.token_secret, "incomplete_token_secret")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue