File: api.py

package info (click to toggle)
python-b2sdk 2.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,228 kB
  • sloc: python: 32,094; sh: 13; makefile: 8
file content (48 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
######################################################################
#
# File: b2sdk/_internal/testing/fixtures/api.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
from __future__ import annotations

import http
import http.client
import os

import pytest

from b2sdk._internal.testing.helpers.api import authorize, get_b2_auth_data, get_realm


@pytest.fixture(scope='session')
def realm():
    yield get_realm()


@pytest.fixture(autouse=True, scope='session')
def set_http_debug():
    if os.environ.get('B2_DEBUG_HTTP'):
        http.client.HTTPConnection.debuglevel = 1


@pytest.fixture(scope='session')
def b2_auth_data():
    try:
        return get_b2_auth_data()
    except ValueError as ex:
        pytest.fail(ex.args[0])


@pytest.fixture(scope='session')
def _b2_api(b2_auth_data, realm):
    b2_api, _ = authorize(b2_auth_data, realm)
    return b2_api


@pytest.fixture(scope='session')
def b2_api(_b2_api, bucket_manager):
    return _b2_api