def test_provide_gcp_credentials_key_content(self, mock_file):
        file_dict = {"foo": "bar"}
        string_file = StringIO()
        file_content = json.dumps(file_dict)
        file_name = "/test/mock-file"
        mock_file_handler = mock_file.return_value.__enter__.return_value
        mock_file_handler.name = file_name
        mock_file_handler.write = string_file.write

        with provide_gcp_credentials(key_file_dict=file_dict):
            self.assertEqual(os.environ[CREDENTIALS], file_name)
            self.assertEqual(file_content, string_file.getvalue())
        self.assertEqual(os.environ[CREDENTIALS], ENV_VALUE)
 def test_provide_gcp_credentials_keep_environment(self):
     key_path = "/test/key-path"
     with provide_gcp_credentials(key_file_path=key_path):
         self.assertEqual(os.environ[CREDENTIALS], key_path)
     self.assertEqual(os.environ[CREDENTIALS], ENV_VALUE)
Пример #3
0
 def test_provide_gcp_credentials_keep_environment(self):
     key_path = "/test/key-path"
     with provide_gcp_credentials(key_file_path=key_path):
         assert os.environ[CREDENTIALS] == key_path
     assert os.environ[CREDENTIALS] == ENV_VALUE