Ejemplo n.º 1
0
 def test_from_key_no_name(self):
     args = [
         'transform', 'fromapikey', '--api-key', os.environ['APIMATIC_KEY'],
         '--format', 'SwaggerYaml', '--download-to',
         TestAPITransformer.output_path
     ]
     arguments = ArgumentParser.parse(args)
     APITransformer.from_key(arguments)
     files = os.listdir(TestAPITransformer.output_path)
     self.assertEqual(len(files), 1)
     self.assertEqual(files[0], "converted.yaml")
     file_size = os.stat(
         os.path.join(TestAPITransformer.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)
Ejemplo n.º 2
0
 def test_from_auth_url(self):
     args = [
         'validate', 'fromauthkey', '--auth-key',
         os.environ['APIMATIC_AUTH_KEY'], '--url',
         'https://raw.githubusercontent.com/DudeSolutions/CoreApi/master/apiary.apib'
     ]
     arguments = ArgumentParser.parse(args)
     with mock.patch(
             'apimaticcli.api_validator.APIValidator.process_summary'
     ) as p_sum:
         APIValidator.from_user(arguments)
         args, kwargs = p_sum.call_args
         self.assertTrue(isinstance(args[0], ValidationSummary))
         self.assertTrue(isinstance(args[0].success, bool))
Ejemplo n.º 3
0
 def test_from_key_with_name(self):
     args = [
         'transform', 'fromapikey', '--api-key', os.environ['APIMATIC_KEY'],
         '--format', 'WADL2009', '--download-to',
         TestAPITransformer.output_path, '--download-as', "test.wadl"
     ]
     arguments = ArgumentParser.parse(args)
     APITransformer.from_key(arguments)
     files = os.listdir(TestAPITransformer.output_path)
     self.assertEqual(len(files), 1)
     self.assertEqual(files[0], arguments.download_as)
     file_size = os.stat(
         os.path.join(TestAPITransformer.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)
Ejemplo n.º 4
0
 def test_from_key_unzipped(self):
     args = [
         'generate', 'fromapikey',
         '--api-key', os.environ['APIMATIC_KEY'],
         '--platform', 'cs_portable_net_lib',
         '--download-to', TestSDKGenerator.output_path
     ]
     arguments = ArgumentParser.parse(args)
     SDKGenerator.from_key(arguments)
     directories = os.listdir(TestSDKGenerator.output_path)
     self.assertEqual(len(directories), 1)
     sdk_folder_path = os.path.join(TestSDKGenerator.output_path, directories[0])
     sdk_files = os.listdir(sdk_folder_path)
     self.assertGreater(len(sdk_files), 1)
Ejemplo n.º 5
0
 def test_validate_from_key(self):
     args = [
         'validate', 'fromapikey', '--api-key',
         os.environ['APIMATIC_ERROR_KEY']
     ]
     arguments = ArgumentParser.parse(args)
     with mock.patch(
             'apimaticcli.api_validator.APIValidator.process_summary'
     ) as p_sum:
         APIValidator.from_key(arguments)
         args, kwargs = p_sum.call_args
         self.assertTrue(isinstance(args[0], ValidationSummary))
         self.assertEqual(args[0].success, False)
         self.assertGreater(len(args[0].errors), 0)
Ejemplo n.º 6
0
 def test_from_auth_file(self):
     args = [
         'validate', 'fromauthkey', '--auth-key',
         os.environ['APIMATIC_AUTH_KEY'], '--file',
         './tests/data/calculator.json'
     ]
     arguments = ArgumentParser.parse(args)
     with mock.patch(
             'apimaticcli.api_validator.APIValidator.process_summary'
     ) as p_sum:
         APIValidator.from_user(arguments)
         args, kwargs = p_sum.call_args
         self.assertTrue(isinstance(args[0], ValidationSummary))
         self.assertEqual(args[0].success, True)
         self.assertEqual(len(args[0].errors), 0)
Ejemplo n.º 7
0
 def test_from_key_renamed_zipped(self):
     name = 'CSharp.zip'
     args = [
         'generate', 'fromapikey',
         '--api-key', os.environ['APIMATIC_KEY'],
         '--platform', 'cs_portable_net_lib',
         '--download-to', TestSDKGenerator.output_path,
         '--download-as', name,
         '--skip-unzip'
     ]
     arguments = ArgumentParser.parse(args)
     SDKGenerator.from_key(arguments)
     files = os.listdir(TestSDKGenerator.output_path)
     self.assertEqual(len(files), 1)
     self.assertEqual(files[0], name)
     file_size = os.stat(os.path.join(TestSDKGenerator.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)
Ejemplo n.º 8
0
 def test_from_user_file_unzipped(self):
     args = [
         'generate', 'fromuser',
         '--email', os.environ['APIMATIC_EMAIL'],
         '--password', os.environ['APIMATIC_PASSWORD'],
         '--name', 'Duuuudes',
         '--file', './tests/data/calculator.json',
         '--platform', 'cs_portable_net_lib',
         '--download-to', TestSDKGenerator.output_path
     ]
     arguments = ArgumentParser.parse(args)
     SDKGenerator.from_user(arguments)
     directories = os.listdir(TestSDKGenerator.output_path)
     self.assertEqual(len(directories), 1)
     sdk_folder_path = os.path.join(TestSDKGenerator.output_path, directories[0])
     sdk_files = os.listdir(sdk_folder_path)
     self.assertGreater(len(sdk_files), 1)
Ejemplo n.º 9
0
 def test_from_user_url_zipped(self):
     args = [
         'generate', 'fromuser',
         '--email', os.environ['APIMATIC_EMAIL'],
         '--password', os.environ['APIMATIC_PASSWORD'],
         '--name', 'Duuuudes',
         '--url', 'https://raw.githubusercontent.com/DudeSolutions/CoreApi/master/apiary.apib',
         '--platform', 'cs_portable_net_lib',
         '--download-to', TestSDKGenerator.output_path,
         '--skip-unzip'
     ]
     arguments = ArgumentParser.parse(args)
     SDKGenerator.from_user(arguments)
     files = os.listdir(TestSDKGenerator.output_path)
     self.assertEqual(len(files), 1)
     self.assertTrue(files[0].endswith(".zip"))
     file_size = os.stat(os.path.join(TestSDKGenerator.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)
Ejemplo n.º 10
0
 def test_from_auth_file_renamed_zipped(self):
     name = 'CSharpCalcy'
     args = [
         'generate', 'fromauthkey',
         '--auth-key', os.environ['APIMATIC_AUTH_KEY'],
         '--name', 'Duuuudes',
         '--file', './tests/data/calculator.json',
         '--platform', 'cs_portable_net_lib',
         '--download-to', TestSDKGenerator.output_path,
         '--download-as', name,
         '--skip-unzip'
     ]
     arguments = ArgumentParser.parse(args)
     SDKGenerator.from_user(arguments)
     files = os.listdir(TestSDKGenerator.output_path)
     self.assertEqual(len(files), 1)
     self.assertEqual(files[0], name + '.zip')
     file_size = os.stat(os.path.join(TestSDKGenerator.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)
Ejemplo n.º 11
0
 def test_from_auth_url_renamed_unzipped(self):
     name = 'Duuuuuuudes'
     args = [
         'generate', 'fromauthkey',
         '--auth-key', os.environ['APIMATIC_AUTH_KEY'],
         '--name', 'Duuuudes',
         '--url', 'https://raw.githubusercontent.com/DudeSolutions/CoreApi/master/apiary.apib',
         '--platform', 'cs_portable_net_lib',
         '--download-to', TestSDKGenerator.output_path,
         '--download-as', name
     ]
     arguments = ArgumentParser.parse(args)
     SDKGenerator.from_user(arguments)
     directories = os.listdir(TestSDKGenerator.output_path)
     self.assertEqual(len(directories), 1)
     self.assertEqual(directories[0], name)
     sdk_folder_path = os.path.join(TestSDKGenerator.output_path, directories[0])
     sdk_files = os.listdir(sdk_folder_path)
     self.assertGreater(len(sdk_files), 1)
Ejemplo n.º 12
0
 def test_from_auth_url(self):
     args = [
         'transform',
         'fromauthkey',
         '--auth-key',
         os.environ['APIMATIC_AUTH_KEY'],
         '--url',
         'https://raw.githubusercontent.com/DudeSolutions/CoreApi/master/apiary.apib',
         '--format',
         'APIMATIC',
         '--download-to',
         TestAPITransformer.output_path,
     ]
     arguments = ArgumentParser.parse(args)
     APITransformer.from_user(arguments)
     files = os.listdir(TestAPITransformer.output_path)
     self.assertEqual(len(files), 1)
     self.assertEqual(files[0], "converted.json")
     file_size = os.stat(
         os.path.join(TestAPITransformer.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)
Ejemplo n.º 13
0
 def test_from_auth_file(self):
     args = [
         'transform',
         'fromauthkey',
         '--auth-key',
         os.environ['APIMATIC_AUTH_KEY'],
         '--file',
         './tests/data/calculator.json',
         '--format',
         'APIBluePrint',
         '--download-to',
         TestAPITransformer.output_path,
     ]
     arguments = ArgumentParser.parse(args)
     APITransformer.from_user(arguments)
     files = os.listdir(TestAPITransformer.output_path)
     self.assertEqual(len(files), 1)
     self.assertEqual(files[0], "converted.apib")
     file_size = os.stat(
         os.path.join(TestAPITransformer.output_path, files[0])).st_size
     self.assertGreater(file_size, 0)