File tree 3 files changed +13
-46
lines changed
3 files changed +13
-46
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,12 @@ classifiers = [
17
17
" Programming Language :: Python :: 3" ,
18
18
]
19
19
dependencies = [
20
+ ' httpx' ,
20
21
' prometheus_client' ,
21
22
' requests' ,
22
23
]
23
24
25
+
24
26
[project .urls ]
25
27
"Bug Reports" = " https://github.com/psyinfra/prometheus-eaton-ups-exporter/issues"
26
28
"Source" = " https://github.com/psyinfra/prometheus-eaton-ups-exporter/"
@@ -30,6 +32,7 @@ tests = [
30
32
' flake8' ,
31
33
' pyre-check' ,
32
34
' pytest == 7.2.1' ,
35
+ ' pytest-asyncio' ,
33
36
' pytest-vcr' ,
34
37
]
35
38
Original file line number Diff line number Diff line change 3
3
"""
4
4
import pytest
5
5
from . import first_ups_details
6
- from prometheus_eaton_ups_exporter .exporter import (
7
- UPSExporter ,
8
- UPSMultiExporter ,
9
- )
6
+ from prometheus_eaton_ups_exporter .exporter import UPSExporter
10
7
11
8
12
- # Create Multi Exporter
13
- @pytest .fixture (scope = "function" )
14
- def single_exporter (ups_scraper_conf ) -> UPSExporter :
15
- address , auth , ups_name = first_ups_details (ups_scraper_conf )
16
- return UPSExporter (
17
- address ,
18
- auth ,
19
- ups_name ,
20
- insecure = True ,
21
- verbose = True
22
- )
23
-
24
-
25
- # Create Multi Exporter
26
- @pytest .fixture (scope = "function" )
27
- def multi_exporter (ups_scraper_conf ) -> UPSMultiExporter :
28
- return UPSMultiExporter (
29
- ups_scraper_conf ,
30
- insecure = True ,
31
- verbose = True
32
- )
33
-
34
-
35
- # Create Multi Exporter
36
- @pytest .fixture (scope = "function" )
37
- def threading_multi_exporter (ups_scraper_conf ) -> UPSMultiExporter :
38
- return UPSMultiExporter (
39
- ups_scraper_conf ,
40
- insecure = True ,
41
- verbose = True ,
42
- threading = True
43
- )
44
-
45
9
46
10
@pytest .mark .vcr ()
47
11
def test_single_collect (ups_scraper_conf , single_exporter ) -> None :
Original file line number Diff line number Diff line change @@ -36,17 +36,17 @@ def scraper_fixture(ups_scraper_conf):
36
36
)
37
37
return ups_scraper (address , auth , ups_name )
38
38
39
-
39
+ @ pytest . mark . asyncio
40
40
@pytest .mark .vcr ()
41
- def test_login (scraper_fixture ) -> None :
42
- token_type , access_token = scraper_fixture .login ()
41
+ async def test_login (scraper_fixture ) -> None :
42
+ token_type , access_token = await scraper_fixture .login ()
43
43
assert token_type == "Bearer"
44
44
45
-
45
+ @ pytest . mark . asyncio
46
46
@pytest .mark .vcr ()
47
- def test_load_rest_api (scraper_fixture ) -> None :
47
+ async def test_load_rest_api (scraper_fixture ) -> None :
48
48
"""Tests load_page function with rest api."""
49
- request = scraper_fixture .load_page (
49
+ request = await scraper_fixture .load_page (
50
50
scraper_fixture .ups_address + REST_API_PATH
51
51
)
52
52
# Todo
@@ -59,10 +59,10 @@ def test_load_rest_api(scraper_fixture) -> None:
59
59
]
60
60
assert response_keys == list (json_response .keys ())
61
61
62
-
62
+ @ pytest . mark . asyncio
63
63
@pytest .mark .vcr ()
64
- def test_get_measures (scraper_fixture ) -> None :
65
- measures = scraper_fixture .get_measures ()
64
+ async def test_get_measures (scraper_fixture ) -> None :
65
+ measures = await scraper_fixture .get_measures ()
66
66
measures_keys = [
67
67
'ups_id' ,
68
68
'ups_inputs' ,
You can’t perform that action at this time.
0 commit comments