Пример #1
0
    def tearDown(self):
        self.client.close()

        for api_ref in self._cleanup_api:
            self.assertTrue(isinstance(api_ref, models.APIReference))
            api_ref = models.APIReference.objects.get(id=api_ref.id)  # reloads!!
            logic.withdraw_api(self.client, api_ref)
Пример #2
0
    def test_withdraw_api(self):
        # Create api_ref
        api_ref = APIReferenceFactory(upstream_url=fake.url(),
                                      request_host=fake.domain_name())

        # Publish
        logic.synchronize_api(self.client, api_ref)
        self.assertTrue(api_ref.synchronized)

        # Check kong
        result = self.client.apis.retrieve(api_ref.kong_id)
        self.assertIsNotNone(result)
        self.assertEqual(result['upstream_url'], api_ref.upstream_url)
        self.assertEqual(result['request_host'], api_ref.request_host)

        # Store kong_id
        kong_id = api_ref.kong_id

        # You can delete afterwards
        logic.withdraw_api(self.client, api_ref)
        self.assertFalse(api_ref.synchronized)

        # Check kong
        with self.assertRaises(ValueError):
            _ = self.client.apis.retrieve(kong_id)
Пример #3
0
    def tearDown(self):
        self.client.close()

        for api_ref in self._cleanup_api:
            self.assertTrue(isinstance(api_ref, models.APIReference))
            api_ref = models.APIReference.objects.get(
                id=api_ref.id)  # reloads!!
            logic.withdraw_api(self.client, api_ref)
Пример #4
0
    def test_withdraw_api(self):
        # Create api_ref
        api_ref = APIReferenceFactory(upstream_url=fake.url(), request_host=fake.domain_name())

        # Publish
        logic.synchronize_api(self.client, api_ref)
        self.assertTrue(api_ref.synchronized)

        # Check kong
        result = self.client.apis.retrieve(api_ref.kong_id)
        self.assertIsNotNone(result)
        self.assertEqual(result['upstream_url'], api_ref.upstream_url)
        self.assertEqual(result['request_host'], api_ref.request_host)

        # Store kong_id
        kong_id = api_ref.kong_id

        # You can delete afterwards
        logic.withdraw_api(self.client, api_ref)
        self.assertFalse(api_ref.synchronized)

        # Check kong
        with self.assertRaises(ValueError):
            _ = self.client.apis.retrieve(kong_id)