11import os .path
22
3+ import pytest
4+
35from gs_api_client import Configuration
46from examples .configloader import load_config
57
68
79CURRENT_DIR = os .path .dirname (os .path .realpath (__file__ ))
810
11+
912def test_debug_is_disabled_by_default ():
1013 config = Configuration ()
1114 assert not config .debug
@@ -17,11 +20,45 @@ def test_tls_certs_are_verified_by_default():
1720
1821
1922def test_load_config_from_yaml ():
20- """" Make sure we can load a config from a given YAML file."""
23+ """Make sure we can load a config from a given YAML file."""
2124
2225 example_config = os .path .join (CURRENT_DIR , "example-config.yaml" )
2326 res = load_config (example_config )
2427 assert isinstance (res , list )
2528 assert len (res ) == 2
29+ assert isinstance (res [0 ], dict )
2630 assert res [0 ]["name" ] == "default"
2731 assert res [1 ]["name" ] == "something-else"
32+
33+
34+ def test_load_config_handles_non_existing_file ():
35+ """ "Ensure load_config raises FileNotFoundError."""
36+
37+ with pytest .raises (FileNotFoundError ):
38+ load_config ("fufu.yaml" )
39+
40+
41+ def test_load_config_checks_for_bogus_input ():
42+ """ "Ensure load_config checks it's input."""
43+
44+ with pytest .raises (AssertionError ):
45+ load_config (42 )
46+
47+ with pytest .raises (AssertionError ):
48+ load_config ("" )
49+
50+
51+ def test_load_config_propagates_parsing_errors ():
52+ """ "Ensure load_config raises any error during parsing."""
53+
54+ import yaml
55+
56+ not_a_yaml_file = os .path .join (CURRENT_DIR , "test_config.py" )
57+ with pytest .raises (yaml .YAMLError ):
58+ load_config (not_a_yaml_file )
59+
60+
61+ def test_load_config_has_doc_string ():
62+ """ "Make sure load_config is documented."""
63+
64+ assert load_config .__doc__
0 commit comments