Skip to content

Commit 5ec8e1f

Browse files
committed
Add GitHub actions: windows unit tests (#1254)
* Adding GitHub Actions CI to run unit tests under Windows * Work around pytest on windows not liking long test ids
1 parent 5e234e8 commit 5ec8e1f

File tree

7 files changed

+117
-0
lines changed

7 files changed

+117
-0
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.github/CODEOWNERS @neo4j/drivers
2+
/.github/workflows/ @neo4j/drivers

.github/workflows/tests.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '5.0'
7+
pull_request:
8+
branches:
9+
- '5.0'
10+
11+
jobs:
12+
win-unit-tests:
13+
name: Windows Unit Tests
14+
runs-on: windows-latest
15+
strategy:
16+
matrix:
17+
python-version:
18+
- semver: '3.7'
19+
tox-factor: 'py37'
20+
- semver: '3.8'
21+
tox-factor: 'py38'
22+
- semver: '3.9'
23+
tox-factor: 'py39'
24+
- semver: '3.10'
25+
tox-factor: 'py310'
26+
- semver: '3.11'
27+
tox-factor: 'py311'
28+
- semver: '3.12'
29+
tox-factor: 'py312'
30+
- semver: '3.13'
31+
tox-factor: 'py313'
32+
steps:
33+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34+
35+
- name: Set up Python ${{ matrix.python-version.semver }}
36+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
37+
with:
38+
python-version: ${{ matrix.python-version.semver }}
39+
cache: 'pip'
40+
- name: Upgrade pip
41+
run: python -m pip install -U pip
42+
- name: Install dev dependencies
43+
run: python -m pip install -Ur requirements-dev.txt
44+
- name: Run unit tests
45+
run: python -m tox -vv -f unit ${{ matrix.python-version.tox-factor }}
46+
47+
gha-conclusion:
48+
name: gha-conclusion
49+
needs: win-unit-tests
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Signal failure
53+
if: ${{ cancelled() || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') }}
54+
run: |
55+
echo "Some workflows have failed!"
56+
exit 1
57+
- name: Signal success
58+
if: ${{ !cancelled() && !contains(needs.*.result, 'cancelled') && !contains(needs.*.result, 'failure') }}
59+
run: echo "All done!"

src/neo4j/_async_compat/network/_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515

1616

17+
from __future__ import annotations
18+
1719
import asyncio
1820
import logging
1921
import socket

tests/unit/async_/io/test_neo4j_pool.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
import inspect
18+
import time
1819

1920
import pytest
2021

@@ -28,6 +29,7 @@
2829
AsyncBolt,
2930
AsyncNeo4jPool,
3031
)
32+
from neo4j._async_compat import async_sleep
3133
from neo4j._async_compat.util import AsyncUtil
3234
from neo4j._conf import (
3335
RoutingConfig,
@@ -45,6 +47,8 @@
4547
from ...._async_compat import mark_async_test
4648

4749

50+
MONOTONIC_TIME_RESOLUTION = time.get_clock_info("monotonic").resolution
51+
4852
ROUTER1_ADDRESS = ResolvedAddress(("1.2.3.1", 9000), host_name="host")
4953
ROUTER2_ADDRESS = ResolvedAddress(("1.2.3.1", 9001), host_name="host")
5054
ROUTER3_ADDRESS = ResolvedAddress(("1.2.3.1", 9002), host_name="host")
@@ -193,6 +197,8 @@ async def test_acquires_new_routing_table_if_stale(
193197
old_value = pool.routing_tables[db.name].last_updated_time
194198
pool.routing_tables[db.name].ttl = 0
195199

200+
await async_sleep(MONOTONIC_TIME_RESOLUTION * 2)
201+
196202
cx = await pool.acquire(READ_ACCESS, 30, db, None, None, None)
197203
await pool.release(cx)
198204
assert pool.routing_tables[db.name].last_updated_time > old_value
@@ -214,6 +220,8 @@ async def test_removes_old_routing_table(opener):
214220
db2_rt = pool.routing_tables[TEST_DB2.name]
215221
db2_rt.ttl = -RoutingConfig.routing_table_purge_delay
216222

223+
await async_sleep(MONOTONIC_TIME_RESOLUTION * 2)
224+
217225
cx = await pool.acquire(READ_ACCESS, 30, TEST_DB1, None, None, None)
218226
await pool.release(cx)
219227
assert pool.routing_tables[TEST_DB1.name].last_updated_time > old_value

tests/unit/async_/test_addressing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ async def test_address_resolve_with_custom_resolver_none() -> None:
5353
@pytest.mark.parametrize(
5454
("test_input", "expected"),
5555
[
56+
(Address(("example.invalid", "7687")), ValueError),
57+
(Address(("example.invalid", 7687)), ValueError),
58+
(Address(("example.invalid", None)), ValueError),
5659
(Address(("127.0.0.1", "abcd")), ValueError),
5760
(Address((None, None)), ValueError),
61+
(Address((1234, "7687")), TypeError),
5862
],
5963
)
6064
@mark_async_test
@@ -67,6 +71,21 @@ async def test_address_resolve_with_unresolvable_address(
6771
)
6872

6973

74+
@pytest.mark.parametrize(
75+
"test_input",
76+
[
77+
Address((None, 7687)),
78+
Address(("example.com", None)),
79+
],
80+
)
81+
@mark_async_test
82+
async def test_address_resolves_with_none(test_input) -> None:
83+
resolved = await AsyncUtil.list(
84+
AsyncNetworkUtil.resolve_address(test_input, resolver=None)
85+
)
86+
assert resolved
87+
88+
7089
@mark_async_test
7190
@pytest.mark.parametrize("resolver_type", ("sync", "async"))
7291
async def test_address_resolve_with_custom_resolver(resolver_type) -> None:

tests/unit/sync/io/test_neo4j_pool.py

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/sync/test_addressing.py

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)