Пример #1
0
	def test_fail(self, build_config, path):
		app_config = {'uuid': 'DUMMY_UUID', 'test': 'config'}
		build_config.load_app.return_value = app_config
		path.isfile.return_value = False
		path.isdir.return_value = True
		self.remote._api_get.return_value = {'build_id': -1, 'state': 'aborted', 'log_output': 'test logging'}
		
		assert_raises_regexp(Exception, 'build failed', self.remote.build, template_only=True)
 def test_copy_files_should_raise_on_attempting_to_copy_to_already_existing_dir(
         self):
     os.makedirs(self._build_dir)
     lib.assert_raises_regexp(
         OSError, 'File exists', tasks.copy_files, self._build, **{
             'from': self._src_dir,
             'to': self._build_dir
         })
Пример #3
0
	def test_no_status_code(self):
		resp = mock.Mock()
		resp.status_code = None
		resp.ok = False
		
		assert_raises_regexp(RequestError, 'got no response',
			remote._check_api_response_for_error,
			'http://dummy.trigger.io/',
			'GET',
			resp,
		)
Пример #4
0
	def test_200_invalid_json(self):
		resp = mock.Mock()
		resp.content = "wat!["
		resp.status_code = 200
		resp.ok = True
		
		assert_raises_regexp(RequestError, 'Server meant to respond with JSON, but response content was',
			remote._check_api_response_for_error,
			'http://dummy.trigger.io/',
			'GET',
			resp,
		)
Пример #5
0
	def test_200_error(self):
		resp = mock.Mock()
		resp.content = json.dumps({'result': 'error', 'text': 'Internal error: testing'})
		resp.status_code = 200
		resp.ok = True
		
		assert_raises_regexp(RequestError, 'Internal error: testing',
			remote._check_api_response_for_error,
			'http://dummy.trigger.io/',
			'GET',
			resp,
		)
Пример #6
0
	def test_500_invalid_json(self):
		resp = mock.Mock()
		resp.content = "wat!["
		resp.status_code = 500
		resp.ok = False
		
		assert_raises_regexp(RequestError, 'GET to http://dummy.trigger.io/ failed',
			remote._check_api_response_for_error,
			'http://dummy.trigger.io/',
			'GET',
			resp,
		)
	def test_copy_files_should_raise_on_attempting_to_copy_to_already_existing_dir(self):
		os.makedirs(self._build_dir)
		lib.assert_raises_regexp(OSError, 'File exists', tasks.copy_files, self._build, **{'from':self._src_dir, 'to':self._build_dir})
	def test_copy_files_should_raise_on_missing_args(self):
		# TODO: pass in a proper build instead of a mock
		lib.assert_raises_regexp(ConfigurationError, 'requires "from" and "to"', tasks.copy_files, mock.Mock())
 def test_copy_files_should_raise_on_missing_args(self):
     # TODO: pass in a proper build instead of a mock
     lib.assert_raises_regexp(ConfigurationError,
                              'requires "from" and "to"', tasks.copy_files,
                              mock.Mock())
Пример #10
0
def test__check_version_old(sys):
	sys.hexversion = 0x0205FFFF
	assert_raises_regexp(Exception, 'please update your interpreter', forge._check_version)
Пример #11
0
	def test_nocsrf(self):
		cookie = Mock()
		cookie.domain = 'other domain'
		self.remote.cookies = [cookie]
		assert_raises_regexp(Exception, "don't have a CSRF token", self.remote._csrf_token)