Skip to content

Commit

Permalink
unsuccessful first steps to test new api/auth.py and `api/request.p…
Browse files Browse the repository at this point in the history
…y` modules

#177
  • Loading branch information
SimonSAMPERE committed Aug 8, 2019
1 parent a5518a4 commit bacc6f9
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/test_api_requester.py
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-

# Standard library
import unittest
import json

# Tested module
from modules import ApiRequester

class TestApiRequester(unittest.TestCase):

def setUp(self):
self.requester = ApiRequester()

def tearDown(self):
pass

def test_setup_api_params(self):
pass

def test_api_auth_post_get_token(self):
pass

def test_api_auth_handle_token(self):
pass

def test_api_get_requests(self):
pass

def test_api_requests_handle_reply(self):
pass

def test_build_request_url(self):
pass


if __name__ == '__main__':
unittest.main()
58 changes: 58 additions & 0 deletions test/test_authenticator.py
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-

# Standard library
import unittest
import json
import os
from pathlib import Path

# PyQT
from qgis.PyQt.QtCore import QSettings


# Tested module
from modules import Authenticator

class TestAuthenticator(unittest.TestCase):

def setUp(self):
auth_folder = Path(__file__).parents[0] / "_auth"
self.authenticator = Authenticator(auth_folder)
self.authenticator.lang = "fr"
self.qsettings = QSettings

def tearDown(self):
pass

def test_instantiation(self):
with self.assertRaises(TypeError):
Authenticator(1)
with self.assertRaises(ValueError):
Authenticator()
self.assertEqual(Authenticator("path").auth_folder, "path")

def test_credentials_check_qsettings(self):
self.qsettings.beginGroup("isogeo-plugin")
self.qsettings.close()
self.assertFalse(self.authenticator.credentials_check_qsettings())

def test_credentials_check_file(self):
os.rename(Path(self.authenticator.auth_folder)/"client_secrets.json", Path(self.authenticator.auth_folder)/"client_secrets_test.json")
self.assertFalse(self.authenticator.credentials_check_file())
os.rename(Path(self.authenticator.auth_folder)/"client_secrets_test.json", Path(self.authenticator.auth_folder)/"client_secrets.json")

def test_credentials_update(self):
pass

def test_credentials_storer(self):
pass

def test_credentials_uploader(self):
pass

def test_manage_api_initialization(self):
pass


if __name__ == '__main__':
unittest.main()

0 comments on commit bacc6f9

Please sign in to comment.