Skip to content

Commit 9bcb356

Browse files
committed
fixup! rename es2/mongo2 fixtures with es_forwarding/mongo_forwarding
1 parent 49deada commit 9bcb356

6 files changed

Lines changed: 41 additions & 31 deletions

File tree

.env.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ RALPH_APP_DIR=/app/.ralph
3939
# RALPH_BACKENDS__DATABASE__ES__INDEX=statements
4040
# RALPH_BACKENDS__DATABASE__ES__TEST_HOSTS=http://elasticsearch:9200
4141
# RALPH_BACKENDS__DATABASE__ES__TEST_INDEX=test-index
42-
# RALPH_BACKENDS__DATABASE__ES__TEST_INDEX_2=test-index-2
42+
# RALPH_BACKENDS__DATABASE__ES__TEST_FORWARDING_INDEX=test-index-2
4343

4444
# MONGO database backend
4545

4646
# RALPH_BACKENDS__DATABASE__MONGO__COLLECTION=foo
4747
# RALPH_BACKENDS__DATABASE__MONGO__DATABASE=statements
4848
# RALPH_BACKENDS__DATABASE__MONGO__CONNECTION_URI=mongodb://localhost:27017/
4949
# RALPH_BACKENDS__DATABASE__MONGO__TEST_COLLECTION=foo
50-
# RALPH_BACKENDS__DATABASE__MONGO__TEST_COLLECTION_2=foo-2
50+
# RALPH_BACKENDS__DATABASE__MONGO__TEST_FORWARDING_COLLECTION=foo-2
5151
# RALPH_BACKENDS__DATABASE__MONGO__TEST_DATABASE=statements
5252
# RALPH_BACKENDS__DATABASE__MONGO__TEST_CONNECTION_URI=mongodb://mongodb:27017/
5353

tests/api/test_statements_post.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
from ralph.exceptions import BackendException
1515

1616
from tests.fixtures.backends import (
17+
ES_TEST_FORWARDING_INDEX,
1718
ES_TEST_HOSTS,
18-
ES_TEST_INDEX_2,
19-
MONGO_TEST_COLLECTION_2,
2019
MONGO_TEST_CONNECTION_URI,
2120
MONGO_TEST_DATABASE,
21+
MONGO_TEST_FORWARDING_COLLECTION,
2222
RUNSERVER_TEST_HOST,
2323
RUNSERVER_TEST_PORT,
2424
get_es_test_backend,
@@ -393,28 +393,28 @@ def spy_mock_forward_xapi_statements(_):
393393

394394
@pytest.mark.asyncio
395395
@pytest.mark.parametrize(
396-
"forwarding_backend", [get_es_test_backend, get_mongo_test_backend]
396+
"receiving_backend", [get_es_test_backend, get_mongo_test_backend]
397397
)
398398
@pytest.mark.parametrize(
399-
"receiving_backend",
399+
"forwarding_backend",
400400
[
401-
lambda: ESDatabase(hosts=ES_TEST_HOSTS, index=ES_TEST_INDEX_2),
401+
lambda: ESDatabase(hosts=ES_TEST_HOSTS, index=ES_TEST_FORWARDING_INDEX),
402402
lambda: MongoDatabase(
403403
connection_uri=MONGO_TEST_CONNECTION_URI,
404404
database=MONGO_TEST_DATABASE,
405-
collection=MONGO_TEST_COLLECTION_2,
405+
collection=MONGO_TEST_FORWARDING_COLLECTION,
406406
),
407407
],
408408
)
409409
async def test_post_statements_list_with_statement_forwarding(
410-
forwarding_backend,
411410
receiving_backend,
411+
forwarding_backend,
412412
monkeypatch,
413413
auth_credentials,
414414
es,
415-
es2,
415+
es_forwarding,
416416
mongo,
417-
mongo2,
417+
mongo_forwarding,
418418
lrs,
419419
):
420420
"""Tests the xAPI forwarding functionality given two ralph instances - a forwarding
@@ -486,7 +486,7 @@ async def test_post_statements_list_with_statement_forwarding(
486486
assert response.status_code == 200
487487

488488
es.indices.refresh()
489-
es2.indices.refresh()
489+
es_forwarding.indices.refresh()
490490

491491
# The statement should be stored on the forwarding client
492492
response = await forwarding_client.get(

tests/backends/database/test_es.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
from ralph.conf import settings
2020
from ralph.exceptions import BackendException, BackendParameterException
2121

22-
from tests.fixtures.backends import ES_TEST_HOSTS, ES_TEST_INDEX, ES_TEST_INDEX_2
22+
from tests.fixtures.backends import (
23+
ES_TEST_FORWARDING_INDEX,
24+
ES_TEST_HOSTS,
25+
ES_TEST_INDEX,
26+
)
2327

2428

2529
def test_backends_database_es_database_instantiation(es):
@@ -465,7 +469,9 @@ def mock_search(**_):
465469
assert caplog.record_tuples == [(logger_name, logging.ERROR, msg)]
466470

467471

468-
def test_backends_database_es_query_statements_by_ids_with_multiple_indexes(es, es2):
472+
def test_backends_database_es_query_statements_by_ids_with_multiple_indexes(
473+
es, es_forwarding
474+
):
469475
"""Tests the ES query_statements_by_ids method, given a valid search
470476
query, should execute the query uniquely on the specified index and return the
471477
expected results.
@@ -474,17 +480,21 @@ def test_backends_database_es_query_statements_by_ids_with_multiple_indexes(es,
474480

475481
# Insert documents
476482
index_1_document = {"_index": ES_TEST_INDEX, "_id": "1", "_source": {"id": "1"}}
477-
index_2_document = {"_index": ES_TEST_INDEX_2, "_id": "2", "_source": {"id": "2"}}
483+
index_2_document = {
484+
"_index": ES_TEST_FORWARDING_INDEX,
485+
"_id": "2",
486+
"_source": {"id": "2"},
487+
}
478488
bulk(es, [index_1_document])
479-
bulk(es2, [index_2_document])
489+
bulk(es_forwarding, [index_2_document])
480490

481491
# As we bulk insert documents, the index needs to be refreshed before making queries
482492
es.indices.refresh(index=ES_TEST_INDEX)
483-
es2.indices.refresh(index=ES_TEST_INDEX_2)
493+
es_forwarding.indices.refresh(index=ES_TEST_FORWARDING_INDEX)
484494

485495
# Instantiate ES Databases
486496
database = ESDatabase(hosts=ES_TEST_HOSTS, index=ES_TEST_INDEX)
487-
database_2 = ESDatabase(hosts=ES_TEST_HOSTS, index=ES_TEST_INDEX_2)
497+
database_2 = ESDatabase(hosts=ES_TEST_HOSTS, index=ES_TEST_FORWARDING_INDEX)
488498

489499
# Check the expected search query results
490500
index_1_document = index_1_document | {"_score": 1.0}

tests/backends/database/test_mongo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
from tests.fixtures.backends import (
2020
MONGO_TEST_COLLECTION,
21-
MONGO_TEST_COLLECTION_2,
2221
MONGO_TEST_CONNECTION_URI,
2322
MONGO_TEST_DATABASE,
23+
MONGO_TEST_FORWARDING_COLLECTION,
2424
)
2525

2626

@@ -459,7 +459,7 @@ def mock_find(**_):
459459

460460

461461
def test_backends_database_mongo_query_statements_by_ids_with_multiple_collections(
462-
mongo, mongo2
462+
mongo, mongo_forwarding
463463
):
464464
"""Tests the mongo backend query_statements_by_ids method, given a valid search
465465
query, should execute the query uniquely on the specified collection and return the
@@ -476,7 +476,7 @@ def test_backends_database_mongo_query_statements_by_ids_with_multiple_collectio
476476
backend_2 = MongoDatabase(
477477
connection_uri=MONGO_TEST_CONNECTION_URI,
478478
database=MONGO_TEST_DATABASE,
479-
collection=MONGO_TEST_COLLECTION_2,
479+
collection=MONGO_TEST_FORWARDING_COLLECTION,
480480
)
481481

482482
# Insert documents

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from .fixtures.auth import auth_credentials # noqa: F401
99
from .fixtures.backends import ( # noqa: F401
1010
es,
11-
es2,
1211
es_data_stream,
12+
es_forwarding,
1313
events,
1414
lrs,
1515
mongo,
16-
mongo2,
16+
mongo_forwarding,
1717
swift,
1818
ws,
1919
)

tests/fixtures/backends.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
ES_TEST_INDEX = os.environ.get(
2727
"RALPH_BACKENDS__DATABASE__ES__TEST_INDEX", "test-index-foo"
2828
)
29-
ES_TEST_INDEX_2 = os.environ.get(
30-
"RALPH_BACKENDS__DATABASE__ES__TEST_INDEX_2", "test-index-foo-2"
29+
ES_TEST_FORWARDING_INDEX = os.environ.get(
30+
"RALPH_BACKENDS__DATABASE__ES__TEST_FORWARDING_INDEX", "test-index-foo-2"
3131
)
3232
ES_TEST_INDEX_TEMPLATE = os.environ.get(
3333
"RALPH_BACKENDS__DATABASE__ES__INDEX_TEMPLATE", "test-index"
@@ -42,8 +42,8 @@
4242
MONGO_TEST_COLLECTION = os.environ.get(
4343
"RALPH_BACKENDS__DATABASE__MONGO__TEST_COLLECTION", "marsha"
4444
)
45-
MONGO_TEST_COLLECTION_2 = os.environ.get(
46-
"RALPH_BACKENDS__DATABASE__MONGO__TEST_COLLECTION_2", "marsha-2"
45+
MONGO_TEST_FORWARDING_COLLECTION = os.environ.get(
46+
"RALPH_BACKENDS__DATABASE__MONGO__TEST_FORWARDING_COLLECTION", "marsha-2"
4747
)
4848
MONGO_TEST_DATABASE = os.environ.get(
4949
"RALPH_BACKENDS__DATABASE__MONGO__TEST_DATABASE", "statements"
@@ -123,10 +123,10 @@ def es():
123123

124124

125125
@pytest.fixture
126-
def es2():
126+
def es_forwarding():
127127
"""Yields a second ElasticSearch test client. See get_es_fixture above."""
128128

129-
for es_client in get_es_fixture(index=ES_TEST_INDEX_2):
129+
for es_client in get_es_fixture(index=ES_TEST_FORWARDING_INDEX):
130130
yield es_client
131131

132132

@@ -161,10 +161,10 @@ def mongo():
161161

162162

163163
@pytest.fixture
164-
def mongo2():
164+
def mongo_forwarding():
165165
"""Yields a second Mongo test client. See get_mongo_fixture above."""
166166

167-
for mongo_client in get_mongo_fixture(collection=MONGO_TEST_COLLECTION_2):
167+
for mongo_client in get_mongo_fixture(collection=MONGO_TEST_FORWARDING_COLLECTION):
168168
yield mongo_client
169169

170170

0 commit comments

Comments
 (0)