From 84453c9af530da8e1d4907f94aff41dbe892c2a4 Mon Sep 17 00:00:00 2001 From: Steven Bal Date: Thu, 17 Oct 2019 16:09:11 +0200 Subject: [PATCH] Added test for latest run page --- .../servervalidation/tests/tests_frontend.py | 32 +++++++++++++++++++ src/vng/servervalidation/urls.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/vng/servervalidation/tests/tests_frontend.py b/src/vng/servervalidation/tests/tests_frontend.py index cb8358d1..d3c04ea2 100644 --- a/src/vng/servervalidation/tests/tests_frontend.py +++ b/src/vng/servervalidation/tests/tests_frontend.py @@ -801,3 +801,35 @@ def test_server_run_detail_uses_latest_results(self): self.assertIn('https://img.shields.io/', response.text) self.assertNotIn('no results yet for this environment', response.text) + + +class LatestServerRunTests(WebTest): + + def setUp(self): + self.user = UserFactory.create() + self.test_scenario = TestScenarioFactory.create() + self.environment = EnvironmentFactory.create( + test_scenario=self.test_scenario, + user=self.user + ) + + def test_latest_run_page_redirects_to_latest_run(self): + server_run1 = ServerRunFactory.create( + test_scenario=self.test_scenario, + user=self.user, + stopped="2019-01-01T12:00:00Z", + environment=self.environment + ) + server_run2 = ServerRunFactory.create( + test_scenario=self.test_scenario, + user=self.user, + stopped="2019-01-01T15:00:00Z", + environment=self.environment + ) + + response = self.app.get(reverse('server_run:server-run_latest', kwargs={ + 'scenario_uuid': self.test_scenario.uuid, + 'env_uuid': self.environment.uuid + }), user=self.user) + + self.assertIn(str(server_run2.id), response.text) diff --git a/src/vng/servervalidation/urls.py b/src/vng/servervalidation/urls.py index 8dc550a4..da144ed7 100644 --- a/src/vng/servervalidation/urls.py +++ b/src/vng/servervalidation/urls.py @@ -26,6 +26,6 @@ path('/', views.ServerRunOutputUuid.as_view(), name='server-run_detail'), path('/', views.TestScenarioList.as_view(), name='test-scenario_list'), path('//', views.ServerRunList.as_view(), name='server-run_list'), - path('//latest', views.LatestRunView.as_view(), name='server-run_latest'), + path('//latest/', views.LatestRunView.as_view(), name='server-run_latest'), # path('', views.ServerRunList.as_view(), name='server-run_list'), ]