From f9e5a3618c7c287c3f2664b68e0957e20724351b Mon Sep 17 00:00:00 2001
From: Steven Bal
Date: Thu, 17 Oct 2019 15:40:05 +0200
Subject: [PATCH 1/3] Added page to show the latest provider run for an
environment
---
src/vng/servervalidation/urls.py | 1 +
src/vng/servervalidation/views.py | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/src/vng/servervalidation/urls.py b/src/vng/servervalidation/urls.py
index c469cebb..8dc550a4 100644
--- a/src/vng/servervalidation/urls.py
+++ b/src/vng/servervalidation/urls.py
@@ -26,5 +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('', views.ServerRunList.as_view(), name='server-run_list'),
]
diff --git a/src/vng/servervalidation/views.py b/src/vng/servervalidation/views.py
index 55e53e56..4c4ac4c0 100644
--- a/src/vng/servervalidation/views.py
+++ b/src/vng/servervalidation/views.py
@@ -586,3 +586,17 @@ def get(self, request, *args, **kwargs):
'scenario_uuid': environment.test_scenario.uuid,
'env_uuid': environment.uuid
}))
+
+
+class LatestRunView(ServerRunOutputUuid):
+ model = ServerRun
+ template_name = 'servervalidation/server-run_detail.html'
+ slug_field = 'uuid'
+ slug_url_kwarg = 'uuid'
+
+ def get_object(self):
+ server_runs = ServerRun.objects.filter(
+ environment__uuid=self.kwargs['env_uuid'],
+ test_scenario__uuid=self.kwargs['scenario_uuid']
+ ).order_by('-stopped')
+ return server_runs.first()
From d161385a91f72bd66099e2149893c1c0fb955596 Mon Sep 17 00:00:00 2001
From: Steven Bal
Date: Thu, 17 Oct 2019 15:40:53 +0200
Subject: [PATCH 2/3] Modified badges to redirect to latest run for environment
---
.../templates/servervalidation/server-run_detail.html | 6 +++---
.../templates/servervalidation/server-run_list.html | 2 +-
.../templates/servervalidation/table/row-server-run.html | 7 -------
.../servervalidation/table/row-test-scenario.html | 2 +-
4 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/vng/servervalidation/templates/servervalidation/server-run_detail.html b/src/vng/servervalidation/templates/servervalidation/server-run_detail.html
index 09d29a54..6c50fd95 100644
--- a/src/vng/servervalidation/templates/servervalidation/server-run_detail.html
+++ b/src/vng/servervalidation/templates/servervalidation/server-run_detail.html
@@ -50,7 +50,7 @@
{% endblocktrans %}
-
+
@@ -383,10 +383,10 @@ HTML snippet
function setBadgeInfo() {
document.getElementById("badge-description").innerHTML = "Shown below is the badge of the most recent provider run with the environment {{ server_run.environment }} that was started by the user {{ object.user }}.";
document.getElementById("badge").src = "https://img.shields.io/endpoint.svg?style=for-the-badge&url={{changing_badge_url|urlencode}}";
- var gitSnippet = '[![Status badge](https://img.shields.io/endpoint.svg?style=for-the-badge&url={{changing_badge_url|urlencode}})]({{changing_badge_url}})'
+ var gitSnippet = '[![Status badge](https://img.shields.io/endpoint.svg?style=for-the-badge&url={{changing_badge_url|urlencode}})]({{request.scheme}}://{{request.get_host}}{% url 'server_run:server-run_latest' object.test_scenario.uuid object.environment.uuid %})'
var htmlSnippet = '\n'
- + '\n'
+ + '\n'
+ ''
// this page's own source code
diff --git a/src/vng/servervalidation/templates/servervalidation/server-run_list.html b/src/vng/servervalidation/templates/servervalidation/server-run_list.html
index 1af43f09..d3ac8482 100644
--- a/src/vng/servervalidation/templates/servervalidation/server-run_list.html
+++ b/src/vng/servervalidation/templates/servervalidation/server-run_list.html
@@ -48,7 +48,7 @@
-
+
diff --git a/src/vng/servervalidation/templates/servervalidation/table/row-server-run.html b/src/vng/servervalidation/templates/servervalidation/table/row-server-run.html
index dd514fa0..869a687f 100644
--- a/src/vng/servervalidation/templates/servervalidation/table/row-server-run.html
+++ b/src/vng/servervalidation/templates/servervalidation/table/row-server-run.html
@@ -71,12 +71,5 @@
{{server_run.status_exec}}
{% endif %}
|
- {% comment %}
-
-
-
-
-
- | {% endcomment %}
{% endspaceless %}
diff --git a/src/vng/servervalidation/templates/servervalidation/table/row-test-scenario.html b/src/vng/servervalidation/templates/servervalidation/table/row-test-scenario.html
index c238d7c8..7e9f15a7 100644
--- a/src/vng/servervalidation/templates/servervalidation/table/row-test-scenario.html
+++ b/src/vng/servervalidation/templates/servervalidation/table/row-test-scenario.html
@@ -15,7 +15,7 @@
{% if last_run %}
-
+
From 84453c9af530da8e1d4907f94aff41dbe892c2a4 Mon Sep 17 00:00:00 2001
From: Steven Bal
Date: Thu, 17 Oct 2019 16:09:11 +0200
Subject: [PATCH 3/3] 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'),
]
|