Beispiel #1
0
def test_session_exception(mock_requests, a_mock_api):
    session = APISession(api_server=an_api, api_key='test')
    session.api = a_mock_api
    session.api.get_workspaces.side_effect = APIServerException('Something went wrong with the API',
                                                          error_response=APIErrorResponse(code=999,
                                                                                          message='mock error'))
    with pytest.raises(APIServerException):
        session.add_time_entry(start_time=None, description='test', project=None)
Beispiel #2
0
""" Add a time entry to a workspace
"""

from os import environ

from clockifyclient.api import APIServer
from clockifyclient.client import APISession

session = APISession(api_server=APIServer("https://api.clockify.me/api/v1"),
                     api_key=environ["API_KEY"])

stopped = session.stop_timer()

if stopped:
    print(f'stopped {stopped}. Set endtime {stopped.end}')
else:
    print('Stopped nothing. No timer was running')
Beispiel #3
0
def test_session(mock_requests, a_mock_api):
    """Run some session commands with a mocked underlying API"""
    session = APISession(api_server=an_api, api_key="test")
    session.api = a_mock_api
    session.add_time_entry(start_time=None, description="test", project=None)
    session.stop_timer()
Beispiel #4
0
 def __init__(self, api_url, api_key):
     self.api_url = api_url
     self.api_key = api_key
     self.session = APISession(api_server=APIServer(api_url),
                               api_key=api_key)
Beispiel #5
0
import os
import json
from clockifyclient.client import APISession
from clockifyclient.api import APIServer

CLOCKIFY_SETUP_FILE = os.path.abspath('../res/report_setup.json')
with open(CLOCKIFY_SETUP_FILE, 'r', encoding='utf-8') as task:
    setup_dict = json.load(task)
api_key = setup_dict['api_key']
url = "https://api.clockify.me/api/v1/"
api_session = APISession(APIServer(url), api_key)
WORKSPACE = [
    ws for ws in api_session.get_workspaces()
    if ws.name == setup_dict['workspace_name']
][0]
# TODO practice generator
CREDENTIALS_FILE = os.path.abspath(
    '../res/' +
    setup_dict['google_credentials_file'])  # имя файла с закрытым ключом
REPORT_SPREADSHEET_ID = setup_dict['report_spreadsheet_id']
REPORT_SHEET_ID = setup_dict['report_sheet_id']
DATA_LINE = 4
PROJECT_COLUMN = 1
weeks_in_RP = [9, 10, 11, 12, 13, 14]
Beispiel #6
0
def test_create_workspace():
    api_key = ''
    api_server = APIServer('https://api.clockify.me/api/v1')
    api_session = APISession(api_server, api_key)
    workspace = api_session.make_workspace('dev1')
    assert workspace.name == 'dev1'