Skip to content

Commit

Permalink
Fix tests, remove Sentry SDK, fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jul 1, 2024
1 parent 407ea5e commit de02319
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 252 deletions.
56 changes: 1 addition & 55 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,58 +49,4 @@ jobs:
version: ${{ needs.version.outputs.version }}
latest: ${{ github.ref == 'refs/heads/main' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
docker-image-name: ${{ vars.DOCKER_IMAGE_NAME }}

update-proof-of-concept:
runs-on: ubuntu-latest
needs:
- build
- version
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
repository: nationalarchives/ds-etna-deployments-proof-of-concept
ref: main
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
- name: Set up git config
run: |
git config user.name "ds-etna-frontend"
git config user.email "<>"
- name: Install jq
run: sudo apt-get install jq
- name: Update config
run: jq --indent 4 '(.services.frontend.version|="${{ needs.version.outputs.version }}")' config-aws-develop.json > tmp.$$.json && mv tmp.$$.json config-aws-develop.json
- name: Push new version
run: |
git add config-aws-develop.json
git commit -m "Update frontend to v${{ needs.version.outputs.version }}"
git push origin main
update-dblclk:
runs-on: ubuntu-latest
needs:
- build
- version
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
repository: nationalarchives/ds-etna
ref: proof-of-concept
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
- name: Set up git config
run: |
git config user.name "ds-etna-frontend"
git config user.email "<>"
- name: Install yq
uses: dcarbone/install-yq-action@v1.1.1
- name: Update config
run: |
yq '(.services.frontend.image|="ghcr.io/${{ github.repository_owner }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ needs.version.outputs.version }}")' docker-compose.yml > tmp.$$.yml && mv tmp.$$.yml docker-compose.yml
yq '(.services.frontend-develop.image|="ghcr.io/${{ github.repository_owner }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ needs.version.outputs.version }}")' docker-compose.yml > tmp.$$.yml && mv tmp.$$.yml docker-compose.yml
- name: Push new version
run: |
git add docker-compose.yml
git commit -m "Update frontend to v${{ needs.version.outputs.version }}"
git push origin proof-of-concept
docker-image-name: example-flask-application
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ In addition to the [base Docker image variables](https://github.com/nationalarch
```sh
poetry run python -m pytest
```

## Format and debug code

```sh
docker compose exec dev format
```
8 changes: 1 addition & 7 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@
'logo': {
'href': url_for('main.index'),
'title': 'The National Archives home page'
},
'navigation': [
{
'text': 'Visit',
'href': 'https://www.nationalarchives.gov.uk/about/visit-us'
},
]
}
}) }}
{% endblock %}

Expand Down
13 changes: 13 additions & 0 deletions app/templates/main/cookies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'base.html' %}

{%- set pageTitle = 'Browse' -%}

{% block content %}
<div class="tna-section">
<div class="tna-container">
<div class="tna-column tna-column--width-2-3 tna-column--width-5-6-medium tna-column--full-small tna-column--full-tiny">
<h1 class="tna-heading-xl">Cookies</h1>
</div>
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion app/templates/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="tna-section">
<div class="tna-container">
<div class="tna-column tna-column--width-2-3 tna-column--width-5-6-medium tna-column--full-small tna-column--full-tiny">
<h1 class="tna-heading-xl">Flask application</h1>
<h1 class="tna-heading-xl">TNA Flask application</h1>
<p class="tna-large-paragraph">We are the official archive of England and Wales.</p>
</div>
</div>
Expand Down
57 changes: 2 additions & 55 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tna-frontend-jinja = "0.1.33"
flask-talisman = "^1.1.0"
pytest = "^8.1.1"
requests-mock = "^1.12.1"
sentry-sdk = {extras = ["flask"], version = "^2.5.1"}

[build-system]
requires = ["poetry-core"]
Expand Down
46 changes: 0 additions & 46 deletions test/lib/test_content_parser.py

This file was deleted.

95 changes: 8 additions & 87 deletions test/main/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class MainBlueprintTestCase(unittest.TestCase):
def setUp(self):
self.app = create_app("config.Test").test_client()
self.domain = "http://localhost"
self.mock_api_url = self.app.application.config["WAGTAIL_API_URL"]

def test_trailing_slash_redirects(self):
rv = self.app.get("/healthcheck/live")
Expand All @@ -21,92 +20,14 @@ def test_healthcheck_live(self):
self.assertEqual(rv.status_code, 200)
self.assertIn("ok", rv.text)

def test_browse(self):
rv = self.app.get("/browse/")
def test_homepage(self):
rv = self.app.get("/")
self.assertEqual(rv.status_code, 200)
self.assertIn("Explore 1,000 years of history", rv.text)

@requests_mock.Mocker()
def test_sitemap_xml(self, m):
mock_endpoint = (
f"{self.mock_api_url}/pages/?offset=0&limit=20&format=json"
)
mock_respsone = {
"meta": {"total_count": 3},
"items": [
{
"id": 3,
"title": "The National Archives Beta",
"url": "/",
"full_url": f"{self.domain}/",
"type_label": "Home",
"teaser_text": "ETNA homepage",
"teaser_image": None,
},
{
"id": 5,
"title": "Explore the collection",
"url": "/explore-the-collection/",
"full_url": f"{self.domain}/explore-the-collection/",
"type_label": "Explorer index",
"teaser_text": "Choose a topic or time period and start exploring some of our most important and unusual records.",
"teaser_image": {
"id": 1305,
"title": "Large collection of letters sent on the Spanish ship La Perla",
"jpeg": {
"url": "/media/images/prize-p.2e16d0ba.fill-600x400.format-jpeg.jpegquality-60_W4BMfq1.jpg",
"full_url": f"{self.domain}/media/images/prize-p.2e16d0ba.fill-600x400.format-jpeg.jpegquality-60_W4BMfq1.jpg",
"width": 600,
"height": 400,
},
"webp": {
"url": "/media/images/prize-.2e16d0ba.fill-600x400.format-webp.webpquality-80_bk8AKep.webp",
"full_url": f"{self.domain}/media/images/prize-.2e16d0ba.fill-600x400.format-webp.webpquality-80_bk8AKep.webp",
"width": 600,
"height": 400,
},
},
},
{
"id": 53,
"title": "Explore by topic",
"url": "/explore-the-collection/explore-by-topic/",
"full_url": f"{self.domain}/explore-the-collection/explore-by-topic/",
"type_label": "Topic explorer index",
"teaser_text": "Our collection shines a light on many aspects of life, from the stories of states to different people's experiences. Browse these topics for just a taste.",
"teaser_image": {
"id": 1352,
"title": "Map of Chertsey Abbey teaser",
"jpeg": {
"url": "/media/images/map-of-.2e16d0ba.fill-600x400.format-jpeg.jpegquality-60_Mh4oeUt.jpg",
"full_url": f"{self.domain}/media/images/map-of-.2e16d0ba.fill-600x400.format-jpeg.jpegquality-60_Mh4oeUt.jpg",
"width": 600,
"height": 400,
},
"webp": {
"url": "/media/images/map-of.2e16d0ba.fill-600x400.format-webp.webpquality-80_e9FuoI4.webp",
"full_url": f"{self.domain}/media/images/map-of.2e16d0ba.fill-600x400.format-webp.webpquality-80_e9FuoI4.webp",
"width": 600,
"height": 400,
},
},
},
],
}
m.get(mock_endpoint, json=mock_respsone)
rv = self.app.get("/sitemap.xml")
self.assertEqual(rv.status_code, 200)
self.assertIn(f"<loc>{self.domain}/</loc>", rv.text)
self.assertIn(
f"<loc>{self.domain}/explore-the-collection/</loc>", rv.text
)
self.assertIn(
f"<loc>{self.domain}/explore-the-collection/explore-by-topic/</loc>",
rv.text,
)
self.assertIn(f"<loc>{self.domain}/browse/</loc>", rv.text)
self.assertIn(f"<loc>{self.domain}/legal/</loc>", rv.text)
self.assertIn(f"<loc>{self.domain}/legal/cookies/</loc>", rv.text)
self.assertIn(
f"<loc>{self.domain}/legal/cookie-details/</loc>", rv.text
'<h1 class="tna-heading-xl">TNA Flask application</h1>', rv.text
)

def test_cookies(self):
rv = self.app.get("/")
self.assertEqual(rv.status_code, 200)
self.assertIn('<h1 class="tna-heading-xl">Cookies</h1>', rv.text)

0 comments on commit de02319

Please sign in to comment.