Skip to content

Commit

Permalink
Stubs for Gigya
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet committed Nov 15, 2020
1 parent ce5cebf commit ea6f46b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/renault_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@


class RenaultException(Exception):
"""Base class for Renault API errors."""
"""Base exception for Renault API errors."""

pass


# Gigya exceptions
class GigyaException(RenaultException):
"""Base exception for Gigya errors."""

pass


class GigyaResponseException(GigyaException):
"""Gigya returned a parsable errors."""

pass
26 changes: 26 additions & 0 deletions src/renault_api/gigya.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Gigya client for authentication."""
import logging

from aiohttp import ClientSession

_LOGGER = logging.getLogger(__name__)


class Gigya(object):
"""Gigya client for authentication."""

def __init__(self, websession: ClientSession) -> None:
"""Initialise Gigya."""
self._websession = websession

async def login(self, user: str, password: str) -> None:
"""Send login to Gigya."""
pass

async def get_person_id(self) -> str:
"""Get person id."""
return "person_id"

async def get_jwt_token(self) -> str:
"""Get JWT token."""
return "jwt_token"
4 changes: 4 additions & 0 deletions tests/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Constants for the test suite fixtures."""
TEST_PASSWORD = "test_password"
TEST_PERSON_ID = "person-id-1"
TEST_USERNAME = "test@example.com"
57 changes: 57 additions & 0 deletions tests/test_gigya.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Test cases for the Renault client API keys."""
import pytest
from aiohttp.client import ClientSession
from tests.const import TEST_PASSWORD
from tests.const import TEST_USERNAME

from renault_api.gigya import Gigya


@pytest.fixture
def gigya(websession=ClientSession) -> Gigya:
"""Fixture for testing Gigya."""
return Gigya(websession=websession)


@pytest.mark.asyncio
async def test_login(gigya: Gigya) -> None:
"""Test valid login response."""
await gigya.login(TEST_USERNAME, TEST_PASSWORD)


@pytest.mark.asyncio
async def test_login_failed(gigya: Gigya) -> None:
"""Test failed login response."""
pass


@pytest.mark.asyncio
async def test_login_missing_session(gigya: Gigya) -> None:
"""Test corrupted login response."""
pass


@pytest.mark.asyncio
async def test_person_id(gigya: Gigya) -> None:
"""Test valid getAccountInfo response."""
await gigya.login(TEST_USERNAME, TEST_PASSWORD)
await gigya.get_person_id()


@pytest.mark.asyncio
async def test_person_id_missing_data(gigya: Gigya) -> None:
"""Test corrupted getAccountInfo response."""
pass


@pytest.mark.asyncio
async def test_get_jwt_token(gigya: Gigya) -> None:
"""Test valid getJWT response."""
await gigya.login(TEST_USERNAME, TEST_PASSWORD)
await gigya.get_jwt_token()


@pytest.mark.asyncio
async def test_get_jwt_token_missing_token(gigya: Gigya) -> None:
"""Test corrupted getJWT response."""
pass

0 comments on commit ea6f46b

Please sign in to comment.