76
76
77
77
78
78
class TestConfigParser (unittest .TestCase ):
79
+ @mock .patch ('os.path.exists' )
80
+ def test_missing_config (self , path_exists ):
81
+ path_exists .return_value = False
82
+ with self .assertRaises (config .GitlabConfigMissingError ):
83
+ config .GitlabConfigParser ('test' )
84
+
85
+ @mock .patch ('os.path.exists' )
79
86
@mock .patch ('six.moves.builtins.open' )
80
- def test_invalid_id (self , m_open ):
87
+ def test_invalid_id (self , m_open , path_exists ):
81
88
fd = six .StringIO (no_default_config )
82
89
fd .close = mock .Mock (return_value = None )
83
90
m_open .return_value = fd
91
+ path_exists .return_value = True
92
+ config .GitlabConfigParser ('there' )
84
93
self .assertRaises (config .GitlabIDError , config .GitlabConfigParser )
85
94
86
95
fd = six .StringIO (valid_config )
@@ -90,12 +99,15 @@ def test_invalid_id(self, m_open):
90
99
config .GitlabConfigParser ,
91
100
gitlab_id = 'not_there' )
92
101
102
+ @mock .patch ('os.path.exists' )
93
103
@mock .patch ('six.moves.builtins.open' )
94
- def test_invalid_data (self , m_open ):
104
+ def test_invalid_data (self , m_open , path_exists ):
95
105
fd = six .StringIO (missing_attr_config )
96
106
fd .close = mock .Mock (return_value = None ,
97
107
side_effect = lambda : fd .seek (0 ))
98
108
m_open .return_value = fd
109
+ path_exists .return_value = True
110
+
99
111
config .GitlabConfigParser ('one' )
100
112
config .GitlabConfigParser ('one' )
101
113
self .assertRaises (config .GitlabDataError , config .GitlabConfigParser ,
@@ -107,11 +119,13 @@ def test_invalid_data(self, m_open):
107
119
self .assertEqual ('Unsupported per_page number: 200' ,
108
120
emgr .exception .args [0 ])
109
121
122
+ @mock .patch ('os.path.exists' )
110
123
@mock .patch ('six.moves.builtins.open' )
111
- def test_valid_data (self , m_open ):
124
+ def test_valid_data (self , m_open , path_exists ):
112
125
fd = six .StringIO (valid_config )
113
126
fd .close = mock .Mock (return_value = None )
114
127
m_open .return_value = fd
128
+ path_exists .return_value = True
115
129
116
130
cp = config .GitlabConfigParser ()
117
131
self .assertEqual ("one" , cp .gitlab_id )
0 commit comments