File: conftest.py

package info (click to toggle)
python-sharkiq 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 172 kB
  • sloc: python: 847; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pytest
import os
from sharkiq.ayla_api import get_ayla_api
from datetime import datetime, timedelta

@pytest.fixture
def dummy_api():
    """AylaApi object with invalid auth creds and attributes populated."""
    username = "myusername@mysite.com"
    password = "mypassword"

    dummy_api = get_ayla_api(username=username, password=password)
    dummy_api._access_token = "token123"
    dummy_api._refresh_token = "token321"
    dummy_api._is_authed = True
    dummy_api._auth_expiration = datetime.now() + timedelta(seconds=700)
    return dummy_api


@pytest.fixture
def sample_api():
    """AylaApi object using user-supplied auth creds via SHARKIQ_USERNAME and 
    SHARKIQ_PASSWORD environement variables."""
    username = os.getenv("SHARKIQ_USERNAME")
    password = os.getenv("SHARKIQ_PASSWORD")

    assert username is not None, "SHARKIQ_USERNAME environment variable unset"
    assert password is not None, "SHARKIQ_PASSWORD environment variable unset"

    return get_ayla_api(username=username, password=password)


@pytest.fixture
def sample_api_logged_in(sample_api):
    """Sample API object with user-supplied creds after performing auth flow."""
    sample_api.sign_in()
    return sample_api