~harlowja/cloud-init/tox-venvs

« back to all changes in this revision

Viewing changes to tests/unittests/test__init__.py

  • Committer: Scott Moser
  • Date: 2014-01-25 03:31:28 UTC
  • Revision ID: smoser@ubuntu.com-20140125033128-jcd1eev048znm2xk
read_file_or_url: raise UrlError with 404 on ENOENT

This makes it easier to call read_file_or_url and handle file or url
errors.  Now read_file_or_url will raise a UrlError in either case
on errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
        mock_readurl = self.mocker.replace(url_helper.readurl,
197
197
                                           passthrough=False)
198
198
        mock_readurl(url, ARGS, KWARGS)
199
 
        self.mocker.result(util.StringResponse(payload))
 
199
        self.mocker.result(url_helper.StringResponse(payload))
200
200
        self.mocker.replay()
201
201
 
202
202
        self.assertEqual((key, url, None),
212
212
        mock_readurl = self.mocker.replace(url_helper.readurl,
213
213
                                           passthrough=False)
214
214
        mock_readurl(url, ARGS, KWARGS)
215
 
        self.mocker.result(util.StringResponse(payload))
 
215
        self.mocker.result(url_helper.StringResponse(payload))
216
216
        self.mocker.replay()
217
217
 
218
218
        self.assertEqual((key, url, payload),
225
225
        cmdline = "ro %s=%s bar=1" % (key, url)
226
226
 
227
227
        self.mocker.replace(url_helper.readurl, passthrough=False)
228
 
        self.mocker.result(util.StringResponse(""))
 
228
        self.mocker.result(url_helper.StringResponse(""))
229
229
        self.mocker.replay()
230
230
 
231
231
        self.assertEqual((None, None, None),