Skip to content

Commit eee26a9

Browse files
fix ! tests
1 parent e9983a9 commit eee26a9

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

tests/contrib/aurora/test_aurora_sync.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import pytest
66
import responses
77
from constance import config
8+
from constance.test import override_config
9+
810
from django.core.cache import cache
911
from pytest_mock import MockerFixture
1012

@@ -76,6 +78,7 @@ def test_sync_all(
7678
cache_setup_and_fake_lock.assert_called_once_with("sync-aurora")
7779

7880

81+
@override_config(AURORA_API_URL="https://hope-dummy.org/api/", AURORA_API_TOKEN="dummy_token")
7982
def test_sync_projects(
8083
mocker: MockerFixture,
8184
mocked_responses: responses.RequestsMock,
@@ -102,6 +105,7 @@ def test_sync_projects(
102105
assert SyncLog.objects.count() == 1
103106

104107

108+
@override_config(AURORA_API_URL="https://hope-dummy.org/api/", AURORA_API_TOKEN="dummy_token")
105109
def test_sync_registrations(
106110
mocker: MockerFixture,
107111
mocked_responses: responses.RequestsMock,

tests/contrib/hope/test_geo.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import responses
12
from typing import TYPE_CHECKING
3+
from constance.test import override_config
24

35
from testutils.factories import FieldDefinitionFactory, FieldsetFactory, FlexFieldFactory
46

@@ -81,16 +83,19 @@
8183
}
8284

8385

84-
def test_validate_child(db, mocked_responses):
85-
mocked_responses.add(mocked_responses.GET, "https://dev-hope.unitst.org/api/rest/lookups/country/", json=COUNTRIES)
86+
@override_config(HOPE_API_URL="https://hope-dummy.org/api/rest", HOPE_API_TOKEN="dummy_token")
87+
def test_validate_child(db, mocked_responses: responses.RequestsMock) -> None:
88+
base_url = "https://hope-dummy.org/api/rest"
89+
mocked_responses.add(method=responses.GET, url=f"{base_url}/lookups/country/", json=COUNTRIES, status=200)
8690
mocked_responses.add(
87-
mocked_responses.GET,
88-
"https://dev-hope.unitst.org/api/rest/areas/?area_type_area_level=1&country_iso_code2=AF",
91+
method=responses.GET,
92+
url=f"{base_url}/areas/?area_type_area_level=1&country_iso_code2=AF",
8993
json=ADMIN1_AF,
94+
status=200,
9095
)
96+
9197
fd1 = FieldDefinitionFactory(field_type=CountryChoice)
9298
fd2 = FieldDefinitionFactory(field_type=Admin1Choice)
93-
9499
fs: Fieldset = FieldsetFactory()
95100
ita = FlexFieldFactory(name="country", definition=fd1, fieldset=fs)
96101
FlexFieldFactory(name="region", master=ita, definition=fd2, fieldset=fs)

tests/contrib/hope/test_r_country.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from hope_flex_fields.models import FieldDefinition
1313

1414

15-
@pytest.mark.vcr
15+
@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
1616
@pytest.mark.xdist_group("remote")
1717
def test_r_country_fetcher():
1818
f = CountryAttributeHandler(
@@ -27,7 +27,7 @@ def test_r_country_fetcher():
2727
assert f.get()
2828

2929

30-
@pytest.mark.vcr
30+
@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
3131
@pytest.mark.xdist_group("remote")
3232
def test_r_country():
3333
fd: FieldDefinition = FieldDefinitionFactory(

tests/test_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_upgrade_admin(mocked_responses: RequestsMock, environment: dict[str, st
123123

124124
@pytest.mark.django_db(transaction=True)
125125
@pytest.mark.default_cassette("test_sync_all.yaml")
126-
@pytest.mark.vcr
126+
@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
127127
@pytest.mark.xdist_group("remote")
128128
def test_upgrade_sync(environment: dict[str, str]) -> None:
129129
out = StringIO()
@@ -135,7 +135,7 @@ def test_upgrade_sync(environment: dict[str, str]) -> None:
135135

136136
@pytest.mark.django_db(transaction=True)
137137
@pytest.mark.default_cassette("test_sync_all.yaml")
138-
@pytest.mark.vcr
138+
@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
139139
@pytest.mark.xdist_group("remote")
140140
def test_sync(environment: dict[str, str]) -> None:
141141
out = StringIO()

tests/test_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def setup_definitions(db):
1414

1515

1616
@pytest.mark.default_cassette("test_sync_all.yaml")
17-
@pytest.mark.vcr
17+
@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
1818
@pytest.mark.xdist_group("remote")
1919
@pytest.mark.parametrize("stdout", [None, StringIO()])
2020
def test_sync_all(stdout):
@@ -23,7 +23,7 @@ def test_sync_all(stdout):
2323
assert "Fetching" in str(stdout.getvalue())
2424

2525

26-
@pytest.mark.vcr
26+
@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
2727
@pytest.mark.xdist_group("remote")
2828
def test_sync_programs():
2929
from country_workspace.models import Office

tests/workspace/test_ws_import.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from constance import config
88
from django.urls import reverse
99
from webtest import forms, Upload
10+
from constance.test import override_config
1011

1112

1213
from country_workspace.state import state
@@ -114,6 +115,7 @@ def form_aurora(
114115
(stub.imported["update_head_name"], 1, 1),
115116
],
116117
)
118+
@override_config(AURORA_API_URL="https://hope-dummy.org/api/rest", AURORA_API_TOKEN="dummy_token")
117119
def test_import_data_aurora_success(
118120
force_migrated_records: None,
119121
program: "CountryProgram",
@@ -146,6 +148,7 @@ def test_import_data_aurora_success(
146148
(stub.imported["invalid_key"], 0, 0, r".*must contain an underscore"),
147149
],
148150
)
151+
@override_config(AURORA_API_URL="https://hope-dummy.org/api/rest", AURORA_API_TOKEN="dummy_token")
149152
def test_import_data_aurora_errors(
150153
force_migrated_records: None,
151154
program: "CountryProgram",

0 commit comments

Comments
 (0)