mirror of
https://github.com/boostorg/website-v2.git
synced 2026-01-19 04:42:17 +00:00
This commit is contained in:
@@ -18,6 +18,23 @@ def test_homepage(library, library_version, version, tp):
|
||||
assert "featured_library" in response.context
|
||||
|
||||
|
||||
def test_homepage_not_fully_imported(
|
||||
library, library_version, version, not_imported_version, tp
|
||||
):
|
||||
"""Ensure homepage excludes versions that are not fully imported"""
|
||||
# Verify the version is indeed not fully imported
|
||||
assert not_imported_version.fully_imported is False
|
||||
|
||||
url = tp.reverse("home")
|
||||
if not url:
|
||||
url = "/"
|
||||
|
||||
response = tp.get_check_200(url)
|
||||
assert "entries" in response.context
|
||||
assert "latest_version" in response.context
|
||||
assert response.context["latest_version"] is not not_imported_version
|
||||
|
||||
|
||||
def test_200_page(db, tp):
|
||||
"""Test a 200 OK page"""
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from libraries.constants import (
|
||||
class VersionQuerySet(models.QuerySet):
|
||||
def active(self):
|
||||
"""Return active versions"""
|
||||
return self.filter(active=True)
|
||||
return self.filter(active=True, fully_imported=True)
|
||||
|
||||
def most_recent(self):
|
||||
"""Return most recent active non-beta version"""
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.2.7 on 2025-10-27 19:08
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("versions", "0024_alter_versionfile_checksum_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name="version",
|
||||
index=models.Index(
|
||||
fields=["active", "fully_imported"],
|
||||
name="versions_ve_active_ae486b_idx",
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -45,6 +45,11 @@ class Version(models.Model):
|
||||
)
|
||||
objects = VersionManager()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=["active", "fully_imported"]),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ def beta_version(db):
|
||||
description="Some awesome description of the library",
|
||||
release_date=datetime.date.today(),
|
||||
beta=True,
|
||||
fully_imported=True,
|
||||
)
|
||||
|
||||
# Make version download file
|
||||
@@ -44,6 +45,31 @@ def version(db):
|
||||
name="boost-1.79.0",
|
||||
description="Some awesome description of the library",
|
||||
release_date=yesterday,
|
||||
fully_imported=True,
|
||||
)
|
||||
|
||||
# Make version download file
|
||||
c = fake_checksum()
|
||||
baker.make(
|
||||
"versions.VersionFile",
|
||||
version=v,
|
||||
checksum=c,
|
||||
url="https://example.com/version_1.tar.gz",
|
||||
)
|
||||
|
||||
return v
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def not_imported_version(db):
|
||||
# Make version that is not fully imported
|
||||
yesterday = datetime.date.today() - datetime.timedelta(days=1)
|
||||
v = baker.make(
|
||||
"versions.Version",
|
||||
name="boost-1.80.0",
|
||||
description="A version that is not fully imported",
|
||||
release_date=yesterday,
|
||||
fully_imported=False,
|
||||
)
|
||||
|
||||
# Make version download file
|
||||
@@ -68,6 +94,7 @@ def inactive_version(db):
|
||||
description="Some old description of the library",
|
||||
release_date=yesterday,
|
||||
active=False,
|
||||
fully_imported=True,
|
||||
)
|
||||
|
||||
# Make version download file
|
||||
@@ -91,6 +118,7 @@ def old_version(db):
|
||||
name="boost-1.70.0",
|
||||
description="Some awesome description of the library",
|
||||
release_date=last_year,
|
||||
fully_imported=True,
|
||||
)
|
||||
|
||||
# Make version download file
|
||||
@@ -116,6 +144,7 @@ def full_version_one(db):
|
||||
description="Some old description of the library for v1.79.0",
|
||||
release_date=yesterday,
|
||||
active=False,
|
||||
fully_imported=True,
|
||||
)
|
||||
|
||||
f1_url = f"{base_url}version1{base_url_suffix}"
|
||||
|
||||
@@ -110,7 +110,7 @@ def test_version_dropdown_strict(
|
||||
|
||||
# Additional setup for most recent non-beta version
|
||||
most_recent_version = Version.objects.create(
|
||||
name=most_recent_name, beta=False, full_release=True
|
||||
name=most_recent_name, beta=False, full_release=True, fully_imported=True
|
||||
)
|
||||
most_recent_version.save()
|
||||
|
||||
@@ -118,12 +118,14 @@ def test_version_dropdown_strict(
|
||||
version.name = version_name
|
||||
version.beta = beta
|
||||
version.full_release = full_release
|
||||
version.fully_imported = True
|
||||
version.save()
|
||||
|
||||
if most_recent_beta_name:
|
||||
beta_version.name = most_recent_beta_name
|
||||
beta_version.beta = True
|
||||
beta_version.full_release = False
|
||||
beta_version.fully_imported = True
|
||||
beta_version.save()
|
||||
|
||||
queryset = Version.objects.get_dropdown_versions()
|
||||
|
||||
Reference in New Issue
Block a user