File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
tests/integration/synapseclient/core Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 11
11
12
12
"""
13
13
14
- import importlib
15
14
import json
16
15
import logging
17
16
import re
18
17
import sys
18
+ from importlib .resources import files
19
19
from typing import Any , Optional
20
20
21
21
import httpx
@@ -37,7 +37,8 @@ def version_check(
37
37
Recommends upgrade, if a newer version exists.
38
38
39
39
This wraps the _version_check function in a try except block.
40
- The purpose of this is so that no exception caught running the version check stops the client from running.
40
+ The purpose of this is so that no exception caught running the version
41
+ check stops the client from running.
41
42
42
43
Arguments:
43
44
current_version: The current version of the package.
@@ -178,7 +179,7 @@ def _get_local_package_metadata() -> dict[str, Any]:
178
179
Returns:
179
180
dict[str, Any]: This will have various fields relating the version of the client
180
181
"""
181
- ref = importlib . resources . files ("synapseclient" ).joinpath ("synapsePythonClient" )
182
+ ref = files ("synapseclient" ).joinpath ("synapsePythonClient" )
182
183
with ref .open ("r" ) as fp :
183
184
pkg_metadata = json .loads (fp .read ())
184
185
return pkg_metadata
Original file line number Diff line number Diff line change 1
1
"""Integration tests for version checking"""
2
2
3
+ from pytest_mock import MockerFixture
4
+
5
+ import synapseclient .core .version_check
3
6
from synapseclient .core .version_check import _get_version_info_from_pypi , version_check
4
7
5
8
6
- async def test_version_check ():
9
+ async def test_version_check (mocker : MockerFixture ):
7
10
"""Integration checks for version_check"""
8
- # Check current version against pypi version file
9
- version_check ()
10
-
11
11
# Should be higher than current version and return true
12
12
assert version_check (current_version = "999.999.999" )
13
13
14
14
# Test out of date version
15
15
assert not version_check (current_version = "0.0.1" )
16
16
17
+ # Assert _get_version_info_from_pypi called when running version_check
18
+ spy = mocker .spy (synapseclient .core .version_check , "_get_version_info_from_pypi" )
19
+ version_check ()
20
+ spy .assert_called_once ()
21
+
17
22
18
23
def test_get_version_info_from_pypi ():
19
24
"""Integration test for _get_version_info_from_pypi"""
You can’t perform that action at this time.
0 commit comments