Esempio n. 1
0
    def test_parsecollection_ctor(self):
        try:
            collection = CollectionParser()
        except Exception as e:
            self.assertTrue(
                isinstance(e, openman.errors.CollectionParserException))

        try:
            collection = CollectionParser.parse()
        except Exception as e:
            self.assertTrue(
                isinstance(e, openman.errors.CollectionParserException))

        try:
            collection = CollectionParser([1, 2])
        except Exception as e:
            self.assertTrue(
                isinstance(e, openman.errors.CollectionParserException))

        # collection should be a valid postman collection
        postmancollection = openman.from_collection(self.collection_file)
        try:
            collection = CollectionParser(postmancollection)
        except Exception as e:
            self.assertTrue(
                isinstance(e, openman.errors.CollectionParserException))
Esempio n. 2
0
 def test_folders(self):
     postmancollection = openman.from_collection(self.collection_file)
     assert isinstance(postmancollection, dict)
     collection = CollectionParser.parse(postmancollection)
     folders = collection.get_folders()
     self.assertIn('Request Methods',
                   [folder.summary for folder in folders])
Esempio n. 3
0
 def test_openapi(self): 
     collection = CollectionParser(from_collection(self.collection_file))
     spec = Spec(collection)
     self.assertEqual(
         '3.0.0',
         spec.openapi
     )
Esempio n. 4
0
 def test_requestitems(self):
     postmancollection = openman.from_collection(self.collection_file)
     assert isinstance(postmancollection, dict)
     collection = CollectionParser.parse(postmancollection)
     requestitems = collection.get_requestitems()
     self.assertIsInstance(requestitems[0], RequestItemParser)
     self.assertIn('PUT Request',
                   [requestitem.summary for requestitem in requestitems])
Esempio n. 5
0
 def test_description(self):
     postmancollection = openman.from_collection(self.collection_file)
     assert isinstance(postmancollection, dict)
     collection = CollectionParser.parse(postmancollection)
     self.assertEqual(
         'Postman Echo is service you can use to test your REST clients and make sample API calls. It provides endpoints for `GET`, `POST`, `PUT`, various auth mechanisms and other utility endpoints.\n\nThe documentation for the endpoints as well as example responses can be found at [https://postman-echo.com](https://postman-echo.com/?source=echo-collection-app-onboarding)',
         collection.description)
     self.assertEqual(
         'Postman Echo is service you can use to test your REST clients and make sample API calls. It provides endpoints for `GET`, `POST`, `PUT`, various auth mechanisms and other utility endpoints.\n\nThe documentation for the endpoints as well as example responses can be found at [https://postman-echo.com](https://postman-echo.com/?source=echo-collection-app-onboarding)',
         collection.get_description())
Esempio n. 6
0
    def test_servers(self):
        collection = CollectionParser(from_collection(self.collection_file))
        spec = Spec(collection)
        self.assertEqual(["http://localhost"], spec.servers)
        spec.add_servers(["http://abc", "http://def"])
        self.assertEqual(["http://localhost", "http://abc", "http://def"],
                         spec.servers)

        spec.add_servers("jhk")
        self.assertEqual(
            ["http://localhost", "http://abc", "http://def", "jhk"],
            spec.servers,
        )
Esempio n. 7
0
    def test_servers(self): 
        collection = CollectionParser(from_collection(self.collection_file))
        spec = Spec(collection)
        self.assertEqual(
            ['http://localhost'],
            spec.servers
        )
        spec.add_servers(['http://abc', 'http://def'])
        self.assertEqual(
            ['http://localhost', 'http://abc', 'http://def'],
            spec.servers
        )

        spec.add_servers('jhk')
        self.assertEqual(
            ['http://localhost', 'http://abc', 'http://def', 'jhk'],
            spec.servers
        )
Esempio n. 8
0
 def test_info(self): 
     collection = CollectionParser(from_collection(self.collection_file))
     spec = Spec(collection)
     self.assertEqual(
         dict(
             title = 'Postman Echo',
             description =  'Postman Echo is service you can use to test your REST clients and make sample API calls. It provides endpoints for `GET`, `POST`, `PUT`, various auth mechanisms and other utility endpoints.\n\nThe documentation for the endpoints as well as example responses can be found at [https://postman-echo.com](https://postman-echo.com/?source=echo-collection-app-onboarding)',
             version = '1.0.0'
         ),
         spec.info
     )
     self.assertEqual(
         dict(
             title = 'Postman Echo',
             description =  'Postman Echo is service you can use to test your REST clients and make sample API calls. It provides endpoints for `GET`, `POST`, `PUT`, various auth mechanisms and other utility endpoints.\n\nThe documentation for the endpoints as well as example responses can be found at [https://postman-echo.com](https://postman-echo.com/?source=echo-collection-app-onboarding)',
             version = '1.0.0'
         ),
         spec.get_info()
     )
Esempio n. 9
0
 def test_name(self):
     postmancollection = openman.from_collection(self.collection_file)
     assert isinstance(postmancollection, dict)
     collection = CollectionParser.parse(postmancollection)
     self.assertEqual('Postman Echo', collection.name)
     self.assertEqual('Postman Echo', collection.get_name())
Esempio n. 10
0
 def test_version(self):
     postmancollection = openman.from_collection(self.collection_file)
     assert isinstance(postmancollection, dict)
     collection = CollectionParser.parse(postmancollection)
     self.assertEqual('v2.1.0', collection.version)
     self.assertEqual('v2.1.0', collection.get_version())
Esempio n. 11
0
 def test_convert(self):
     collection = CollectionParser(from_collection(self.collection_file))
     spec = Spec(collection)
     with open('test.yaml', 'w') as f:
         f.write(spec.convert(yaml=True))
     #print(spec.convert(yaml=True))