예제 #1
0
 def test_wolfram_api_call_async(self):
     api = (self.api_owner, "api/private/stringreverse")
     apicall = WolframAPICall(self.cloud_session, api)
     apicall.set_parameter("str", "abcde")
     future = apicall.perform_future()
     res = future.result()
     self.assertEqual('"edcba"', force_text(res.get()))
예제 #2
0
 def test_api_permission_key(self):
     with WolframCloudSession(server=server) as cloud:
         url = "api/public/permkey_stringreverse_wxf"
         api = (self.api_owner, url)
         apicall = WolframAPICall(cloud, api, permission_key="my_key")
         apicall.set_parameter("str", "abcde")
         response = apicall.perform()
         self.assertEqual("edcba", response.get())
예제 #3
0
 def test_api_permission_key(self):
     with WolframCloudSession(server=server) as cloud:
         url = 'api/public/permkey_stringreverse_wxf'
         api = (self.api_owner, url)
         apicall = WolframAPICall(cloud, api, permission_key='my_key')
         apicall.set_parameter('str', 'abcde')
         response = apicall.perform()
         self.assertEqual('edcba', response.get())
예제 #4
0
 def test_wolfram_api_call_named_image(self):
     api = (self.api_owner, "api/private/imagedimensions")
     apicall = WolframAPICall(self.cloud_session, api)
     with open(self.get_data_path("32x2.png"), "rb") as fp:
         apicall.add_file_parameter("image", fp, filename="testimage")
         res = apicall.perform()
         self.assertTrue(res.success)
         res = res.get()
         self.assertEqual(res, [32, 2])
예제 #5
0
 def test_wolfram_api_call_named_image(self):
     api = (self.api_owner, 'api/private/imagedimensions')
     apicall = WolframAPICall(self.cloud_session, api)
     with open(self.get_data_path('32x2.png'), 'rb') as fp:
         apicall.add_file_parameter('image', fp, filename='testimage')
         res = apicall.perform()
         self.assertTrue(res.success)
         res = res.get()
         self.assertListEqual(res, [32, 2])
예제 #6
0
 def test_api_invalid_input(self):
     api_urls = ('api/private/two_parameters_out_json',
                 'api/private/two_parameters_out_wxf',
                 'api/private/two_parameters_out_default')
     for url in api_urls:
         api = (self.api_owner, url)
         apicall = WolframAPICall(self.cloud_session, api)
         apicall.set_parameter('x', 'abc')
         res = apicall.perform()
         self.assertFalse(res.success)
예제 #7
0
 def test_wolfram_api_image_string_int(self):
     api = (self.api_owner, "api/private/str_image_int")
     with open(self.get_data_path("32x2.png"), "rb") as fp:
         buffer = fp.read()
     apicall = WolframAPICall(self.cloud_session, api)
     apicall.set_parameter("str", "abc")
     apicall.set_parameter("int", 10)
     apicall.add_image_data_parameter("image", buffer)
     result = apicall.perform().get()
     res = result
     self.assertEqual(res, ["abc", [32, 2], 10])
예제 #8
0
 def test_wolfram_api_image_string_int(self):
     api = (self.api_owner, 'api/private/str_image_int')
     with open(self.get_data_path('32x2.png'), 'rb') as fp:
         buffer = fp.read()
     apicall = WolframAPICall(self.cloud_session, api)
     apicall.set_parameter('str', 'abc')
     apicall.set_parameter('int', 10)
     apicall.add_image_data_parameter('image', buffer)
     result = apicall.perform().get()
     res = result
     self.assertListEqual(res, ['abc', [32, 2], 10])
예제 #9
0
 def test_wolfram_api_call_str(self):
     api = (self.api_owner, "api/private/stringreverse")
     apicall = WolframAPICall(self.cloud_session, api)
     apicall.set_parameter("str", "abcde")
     res = apicall.perform().get()
     self.assertEqual('"edcba"', force_text(res))