Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Fix broken tests

blueheron786455a49678962
diff --git a/mwmbl/migrations/0039_batches_device_name.py b/mwmbl/migrations/0039_batches_device_name.py
index b7b9544..ae32c2d 100644
--- a/mwmbl/migrations/0039_batches_device_name.py
+++ b/mwmbl/migrations/0039_batches_device_name.py
@@ -11,7 +11,12 @@ class Migration(migrations.Migration):
operations = [
migrations.RunSQL(
"""
- ALTER TABLE batches ADD COLUMN device_name VARCHAR;
+ CREATE TABLE IF NOT EXISTS batches (
+ url VARCHAR PRIMARY KEY,
+ user_id_hash VARCHAR NOT NULL,
+ status INT NOT NULL,
+ device_name VARCHAR
+ );
""",
"""
ALTER TABLE batches DROP COLUMN device_name;
diff --git a/test/conftest.py b/test/conftest.py
index 3fab119..c25ce9b 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -31,3 +31,11 @@ def async_debug_loop(event_loop):
event_loop.set_debug(True)
event_loop.slow_callback_duration = 0.1
yield event_loop
+
+
+def index_db():
+ """Create the index database tables (batches, etc.) for tests that need them."""
+ from mwmbl.apps import create_index_db
+
+ create_index_db()
diff --git a/test/test_export_judgments.py b/test/test_export_judgments.py
index d7fc3fe..00e2bce 100644
--- a/test/test_export_judgments.py
+++ b/test/test_export_judgments.py
@@ -11,6 +11,14 @@ from mwmbl.models import Curation, DomainSubmission, FlagCuration, SearchResultV
User = get_user_model()
[email protected](autouse=True)
+def index_db():
+ """Create the index database tables for tests that need them."""
+ from mwmbl.apps import create_index_db
+
+ create_index_db()
+
+
def doc(url, title="title", extract="extract", score=1.0, state=None, user_ids=None):
return {
"url": url,
diff --git a/test/test_large_url_list.py b/test/test_large_url_list.py
index 56c3a98..107c335 100644
--- a/test/test_large_url_list.py
+++ b/test/test_large_url_list.py
@@ -10,6 +10,14 @@ from mwmbl.models import SearchResultVote
User = get_user_model()
[email protected](autouse=True)
+def index_db():
+ """Create the index database tables for tests that need them."""
+ from mwmbl.apps import create_index_db
+
+ create_index_db()
+
+
@pytest.fixture
def verified_user():
"""Create a user with verified email"""
diff --git a/test/test_marketing_consent.py b/test/test_marketing_consent.py
index c44bff9..8d857b2 100644
--- a/test/test_marketing_consent.py
+++ b/test/test_marketing_consent.py
@@ -15,6 +15,14 @@ CONSENT_URL = "/api/v1/platform/marketing-consent"
UNSUBSCRIBE_URL = "/api/v1/platform/marketing/unsubscribe"
[email protected](autouse=True)
+def index_db():
+ """Create the index database tables for tests that need them."""
+ from mwmbl.apps import create_index_db
+
+ create_index_db()
+
+
@pytest.fixture
def verified_user(db):
user = User.objects.create_user(