<reponame>idfy-io/idfy-sdk-python<gh_stars>0
import asyncio
import unittest
import unittest.mock

from test.base_test import BaseTest
from idfy_sdk.version import version

import idfy_sdk

class TestJwt(BaseTest):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.jwt_service = idfy_sdk.services.JwtService()
    
    def test_validate(self):
        data = self.jwt_service.validate(jwt_validation_request=self.params)

        self.assertIsNotNone(data)
        #self.AssertEqual()
        self.mock_http.post.assert_called_once_with('{}/jwt/validate'.format(self.base_url), auth=None, data='{"unit": "test"}', headers={'X-Idfy-SDK': 'Python {}'.format(version), 'Authorization': 'Bearer <KEY>', 'Content-Type': 'application/json'}, params=None)

class TestJwtAsync(BaseTest):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.jwt_service = idfy_sdk.services.JwtService()

    def setUp(self):
        super().setUp()
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)
    
    def tearDown(self):
        self.loop.close()
    
    def test_validate_async(self):
        async def func():
            return await self.jwt_service.validate(jwt_validation_request=self.params, threaded=True)
        data = self.loop.run_until_complete(func())
        
        self.assertIsNotNone(data)
        #self.AssertEqual()
        self.mock_http.post.assert_called_once_with('{}/jwt/validate'.format(self.base_url), auth=None, data='{"unit": "test"}', headers={'X-Idfy-SDK': 'Python {}'.format(version), 'Authorization': 'Bearer <KEY>', 'Content-Type': 'application/json'}, params=None)


import asyncio
import unittest
import unittest.mock

from test.base_test import BaseTest
from idfy_sdk.version import version

import idfy_sdk

class TestJwt(BaseTest):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.jwt_service = idfy_sdk.services.JwtService()
    
    def test_validate(self):
        data = self.jwt_service.validate(jwt_validation_request=self.params)

        self.assertIsNotNone(data)
        #self.AssertEqual()
        self.mock_http.post.assert_called_once_with('{}/jwt/validate'.format(self.base_url), auth=None, data='{"unit": "test"}', headers={'X-Idfy-SDK': 'Python {}'.format(version), 'Authorization': 'Bearer <KEY>', 'Content-Type': 'application/json'}, params=None)

class TestJwtAsync(BaseTest):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.jwt_service = idfy_sdk.services.JwtService()

    def setUp(self):
        super().setUp()
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)
    
    def tearDown(self):
        self.loop.close()
    
    def test_validate_async(self):
        async def func():
            return await self.jwt_service.validate(jwt_validation_request=self.params, threaded=True)
        data = self.loop.run_until_complete(func())
        
        self.assertIsNotNone(data)
        #self.AssertEqual()
        self.mock_http.post.assert_called_once_with('{}/jwt/validate'.format(self.base_url), auth=None, data='{"unit": "test"}', headers={'X-Idfy-SDK': 'Python {}'.format(version), 'Authorization': 'Bearer <KEY>', 'Content-Type': 'application/json'}, params=None)
#self.AssertEqual() #self.AssertEqual()