File tree 3 files changed +12
-45
lines changed
3 files changed +12
-45
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 2
2
Testing the Exporter using the UPSExporter and UPSMultiExporter.
3
3
"""
4
4
import pytest
5
- from . import first_ups_details
6
- from prometheus_eaton_ups_exporter .exporter import (
7
- UPSExporter ,
8
- UPSMultiExporter ,
9
- )
10
-
11
-
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
5
45
6
46
7
@pytest .mark .vcr ()
Original file line number Diff line number Diff line change @@ -37,16 +37,18 @@ def scraper_fixture(ups_scraper_conf):
37
37
return ups_scraper (address , auth , ups_name )
38
38
39
39
40
+ @pytest .mark .asyncio
40
41
@pytest .mark .vcr ()
41
- def test_login (scraper_fixture ) -> None :
42
- token_type , access_token = scraper_fixture .login ()
42
+ async def test_login (scraper_fixture ) -> None :
43
+ token_type , access_token = await scraper_fixture .login ()
43
44
assert token_type == "Bearer"
44
45
45
46
47
+ @pytest .mark .asyncio
46
48
@pytest .mark .vcr ()
47
- def test_load_rest_api (scraper_fixture ) -> None :
49
+ async def test_load_rest_api (scraper_fixture ) -> None :
48
50
"""Tests load_page function with rest api."""
49
- request = scraper_fixture .load_page (
51
+ request = await scraper_fixture .load_page (
50
52
scraper_fixture .ups_address + REST_API_PATH
51
53
)
52
54
# Todo
@@ -60,9 +62,10 @@ def test_load_rest_api(scraper_fixture) -> None:
60
62
assert response_keys == list (json_response .keys ())
61
63
62
64
65
+ @pytest .mark .asyncio
63
66
@pytest .mark .vcr ()
64
- def test_get_measures (scraper_fixture ) -> None :
65
- measures = scraper_fixture .get_measures ()
67
+ async def test_get_measures (scraper_fixture ) -> None :
68
+ measures = await scraper_fixture .get_measures ()
66
69
measures_keys = [
67
70
'ups_id' ,
68
71
'ups_inputs' ,
You can’t perform that action at this time.
0 commit comments