Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions bedrock/base/templates/cron-health-check.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ <h1 id="other-data">Other Site Data</h1>
<td>{{ most_recent_data_change_ts }}</td>
</tr>
{% endif %}
<tr>
<td><b>Latest Contentful sync</b></td>
<td{% if contentful_info.latest_sync %} title="{{contentful_info.latest_sync|datetime(settings.STRFTIME_FORMAT_INTERNAL_USE)}}"{% endif %}>
{% if contentful_info.time_since_latest_sync %}
{{ contentful_info.time_since_latest_sync }}
{% else %}
No data!
{% endif %}
</td>
</tr>
</tbody>
</table>

Expand Down
1 change: 0 additions & 1 deletion bedrock/base/tests/data/example_sentry_payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@
"click": "8.0.4",
"commonware": "0.6.0",
"compare-locales": "7.6.0",
"contentful": "1.13.1",
"contextlib2": "0.5.4",
"coverage": "6.3.2",
"cryptography": "36.0.1",
Expand Down
35 changes: 1 addition & 34 deletions bedrock/base/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

import datetime
from unittest.mock import patch

from django.conf import settings
from django.test import RequestFactory, TestCase
from django.utils.timezone import now as tz_now

import pytest

from bedrock.base.views import GeoTemplateView, get_contentful_sync_info, page_gone_view, page_not_found_view, server_error_view
from bedrock.contentful.models import ContentfulEntry
from bedrock.base.views import GeoTemplateView, page_gone_view, page_not_found_view, server_error_view

geo_template_view = GeoTemplateView.as_view(
geo_template_names={
Expand Down Expand Up @@ -76,36 +73,6 @@ def test_500_handler(self):
self.check_error_handler(server_error_view, "500.html", 500)


@patch("bedrock.base.views.tz_now")
@patch("bedrock.base.views.timeago.format")
@pytest.mark.django_db
def test_get_contentful_sync_info(mock_timeago_format, mock_tz_now):
mock_timeago_format.return_value = "mock-formatted-time-delta"
_now = datetime.datetime.utcnow().replace(tzinfo=datetime.UTC)
mock_tz_now.return_value = _now

middle = tz_now()
first = middle - datetime.timedelta(hours=3)
last = middle + datetime.timedelta(hours=3)

for idx, timestamp in enumerate([middle, last, first]):
ContentfulEntry.objects.create(
contentful_id=f"id-{idx}",
last_modified=timestamp,
)

assert get_contentful_sync_info() == {
"latest_sync": last,
"time_since_latest_sync": "mock-formatted-time-delta",
}

mock_timeago_format.assert_called_once_with(last, now=_now)

# Also check the no-data context dict:
ContentfulEntry.objects.all().delete()
assert get_contentful_sync_info() == {}


@pytest.mark.django_db
def test_csrf_view_is_custom_one():
assert settings.CSRF_FAILURE_VIEW == "bedrock.base.views.csrf_failure"
21 changes: 0 additions & 21 deletions bedrock/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from django.conf import settings
from django.shortcuts import render
from django.utils.decorators import decorator_from_middleware
from django.utils.timezone import now as tz_now
from django.views.decorators.cache import never_cache
from django.views.decorators.http import require_safe

Expand All @@ -21,7 +20,6 @@
from bedrock.base.geo import get_country_from_request
from bedrock.base.i18n import get_language_from_headers
from bedrock.base.middleware import BedrockLocaleMiddleware
from bedrock.contentful.models import ContentfulEntry
from bedrock.utils import git
from lib import l10n_utils

Expand Down Expand Up @@ -108,24 +106,6 @@ def get_extra_server_info():
return server_info


def get_contentful_sync_info():
data = {}
latest = ContentfulEntry.objects.order_by("last_modified").last()
if latest:
latest_sync = latest.last_modified
time_since_latest_sync = timeago.format(
latest_sync,
now=tz_now(),
)
data.update(
{
"latest_sync": latest_sync,
"time_since_latest_sync": time_since_latest_sync,
}
)
return data


@require_safe
@never_cache
def cron_health_check(request):
Expand Down Expand Up @@ -172,7 +152,6 @@ def cron_health_check(request):
{
"results": results,
"server_info": get_extra_server_info(),
"contentful_info": get_contentful_sync_info(),
"success": check_pass,
"git_repos": unique_repos.values(),
"fluent_repo": get_l10n_repo_info(),
Expand Down
2 changes: 2 additions & 0 deletions bedrock/cms/cms_only_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ def dummy_view(*args, **kwargs):
# path("url/path/here/", dummy_view, name="route.name.here"),
path("about/leadership/", dummy_view, name="mozorg.about.leadership.index"),
path("products/monitor/", dummy_view, name="products.monitor.landing"),
path("products/vpn/resource-center/", dummy_view, name="products.vpn.resource-center.landing"),
path("products/vpn/resource-center/<slug:slug>/", dummy_view, name="products.vpn.resource-center.article"),
path("advertising/", dummy_view, name="mozorg.advertising.landing"),
)
3 changes: 0 additions & 3 deletions bedrock/contentful/__init__.py

This file was deleted.

Loading
Loading