def test_send_file_headers(self, mock_requests, mock_getenv): # Ensure that the request gets sent with sensor_ext_only mock_requests.get.return_value.json.return_value = { 'headers': 'headers!', 'url': 'url!', 'method': 'SUPERGET', 'path': 'remote_path!', } response = requests.Response() response.status_code = REQUEST_ENTITY_TOO_LARGE mock_requests.request.return_value = response env_dict = {ENV_OBSRVBL_SENSOR_EXT_ONLY: 'true'} mock_getenv.side_effect = env_dict.get api = Api() time = datetime.utcnow() with NamedTemporaryFile() as f: f.write("hee hee hee") f.seek(0) api.send_file('mytype', f.name, time) self.assertEqual(mock_requests.get.call_args[1]['headers'], {'sensor-ext-only': 'true'})
def setUp(self): self.auth = ('service_key', 'my_key') os.environ[ENV_OBSRVBL_SERVICE_KEY] = self.auth[1] self.api = Api() self.api.ona_name = 'foo'