Skip to content

Commit

Permalink
test: view test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danjac committed Oct 14, 2024
1 parent e16d661 commit 0a0f514
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The `ansible` directory contains full Playbooks for a multi-server deployment to

### Deployment with Hetzner

A full deployment guide for Hetzner Cloud is available.
A full deployment guide for Hetzner Cloud is available. You should have a DNS domain set up using e.g. Hetzner DNS or Cloudflare.

1. [Create a new Hetzner Cloud project](https://docs.hetzner.com/cloud/)
2. Go to Security > API Tokens and create a new token with read/write access
Expand All @@ -94,6 +94,7 @@ A full deployment guide for Hetzner Cloud is available.
6. Change to the `ansible` directory and use `ansible-vault create hosts` to create a new inventory file and add the IP addresses of all the servers
7. Do the same for `vars/django.yml`, `vars/postgres.yml`, and `vars/site.yml` to create the necessary variables (see example vars files for guidance)
8. Run `ansible-playbook -i hosts site.yml` to deploy the application
9. In your DNS configuration, point your domain to the new load balancer IP address

### Scheduling background tasks

Expand Down
14 changes: 14 additions & 0 deletions radiofeed/episodes/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TestIndex:
def test_no_episodes(self, client, auth_user):
response = client.get(_index_url)
assert200(response)
assertTemplateUsed(response, "episodes/index.html")
assert len(response.context["page"].object_list) == 0

@pytest.mark.django_db
Expand All @@ -49,6 +50,7 @@ def test_has_no_subscriptions(self, client, auth_user):
response = client.get(_index_url)

assert200(response)
assertTemplateUsed(response, "episodes/index.html")
assert len(response.context["page"].object_list) == 0

@pytest.mark.django_db
Expand All @@ -59,6 +61,7 @@ def test_has_subscriptions(self, client, auth_user):
response = client.get(_index_url)

assert200(response)
assertTemplateUsed(response, "episodes/index.html")
assert len(response.context["page"].object_list) == 1


Expand All @@ -71,13 +74,15 @@ def test_search(self, auth_user, client, faker):
episode = EpisodeFactory(title=faker.unique.name())
response = client.get(self.url, {"search": episode.title})
assert200(response)
assertTemplateUsed(response, "episodes/search.html")
assert len(response.context["page"].object_list) == 1
assert response.context["page"].object_list[0] == episode

@pytest.mark.django_db
def test_search_no_results(self, auth_user, client):
response = client.get(self.url, {"search": "zzzz"})
assert200(response)
assertTemplateUsed(response, "episodes/search.html")
assert len(response.context["page"].object_list) == 0

@pytest.mark.django_db
Expand Down Expand Up @@ -109,6 +114,7 @@ def episode(self, faker):
def test_ok(self, client, auth_user, episode):
response = client.get(episode.get_absolute_url())
assert200(response)
assertTemplateUsed(response, "episodes/detail.html")
assert response.context["episode"] == episode

@pytest.mark.django_db
Expand All @@ -123,6 +129,7 @@ def test_listened(self, client, auth_user, episode):
response = client.get(episode.get_absolute_url())

assert200(response)
assertTemplateUsed(response, "episodes/detail.html")
assert response.context["episode"] == episode

assertContains(response, "Remove episode from your History")
Expand All @@ -133,6 +140,7 @@ def test_no_prev_next_episode(self, client, auth_user, episode):
response = client.get(episode.get_absolute_url())

assert200(response)
assertTemplateUsed(response, "episodes/detail.html")
assert response.context["episode"] == episode
assertNotContains(response, "No More Episodes")

Expand All @@ -143,6 +151,7 @@ def test_no_next_episode(self, client, auth_user, episode):
)
response = client.get(episode.get_absolute_url())
assert200(response)
assertTemplateUsed(response, "episodes/detail.html")
assert response.context["episode"] == episode
assertContains(response, "Last Episode")

Expand All @@ -153,6 +162,7 @@ def test_no_previous_episode(self, client, auth_user, episode):
)
response = client.get(episode.get_absolute_url())
assert200(response)
assertTemplateUsed(response, "episodes/detail.html")
assert response.context["episode"] == episode
assertContains(response, "First Episode")

Expand All @@ -168,6 +178,7 @@ def test_play_from_start(self, client, auth_user, episode):
},
)
assert200(response)
assertContains(response, 'id="audio-player-button"')

assert AudioLog.objects.filter(user=auth_user, episode=episode).exists()
assert client.session[PlayerDetails.session_id] == episode.pk
Expand All @@ -184,6 +195,7 @@ def test_another_episode_in_player(self, client, auth_user, player_episode):
)

assert200(response)
assertContains(response, 'id="audio-player-button"')

assert AudioLog.objects.filter(user=auth_user, episode=episode).exists()

Expand All @@ -200,6 +212,7 @@ def test_resume(self, client, auth_user, player_episode):
)

assert200(response)
assertContains(response, 'id="audio-player-button"')

assert client.session[PlayerDetails.session_id] == player_episode.pk

Expand Down Expand Up @@ -237,6 +250,7 @@ def test_close(
)

assert200(response)
assertContains(response, 'id="audio-player-button"')

assert player_episode.pk not in client.session

Expand Down

0 comments on commit 0a0f514

Please sign in to comment.