Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Issue/provider tests improvements #196

Merged
merged 3 commits into from
Oct 17, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{% endblocktrans %}
</p>
<span display="block" style='width: 250px;' class="common__BadgeWrapper-sc-16zh6vt-3 fagfmg">
<a href="{% url 'server_run:server-run_detail' object.uuid %}">
<a href="{% url 'server_run:server-run_latest' object.test_scenario.uuid object.environment.uuid %}">

<img id="badge" style='width:250px' alt="" src="">
</a>
Expand Down Expand Up @@ -383,10 +383,10 @@ <h5 class="card-title">HTML snippet</h5>
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 <b>{{ object.user }}</b>.";
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 = '<span display="block" height="20px" class="common__BadgeWrapper-sc-16zh6vt-3 fagfmg">\n'
+ '<a href="{{request.scheme}}://{{request.get_host}}{% url 'server_run:server-run_detail' object.uuid %}">\n'
+ '<a href="{{request.scheme}}://{{request.get_host}}{% url 'server_run:server-run_latest' object.test_scenario.uuid object.environment.uuid %}">\n'
+ '<img style="width:100%" alt="" src="https://img.shields.io/endpoint.svg?style=for-the-badge&url={{changing_badge_url|urlencode}}"></span></a>'

// this page's own source code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<tr>
<td>
<span display="block" class="common__BadgeWrapper-sc-16zh6vt-3 fagfmg">
<a href="{% url 'server_run:server-run_list' test_scenario.uuid environment.uuid %}">
<a href="{% url 'server_run:server-run_latest' test_scenario.uuid environment.uuid %}">
<img style="height:30px" alt="" src="https://img.shields.io/endpoint.svg?style=for-the-badge&amp;url={{request.scheme}}://{{request.get_host}}{% url 'apiv1server:latest-badge' environment.uuid %}">
</a>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,5 @@
{{server_run.status_exec}}
{% endif %}
</td>
{% comment %} <td>
<span display="block" class="common__BadgeWrapper-sc-16zh6vt-3 fagfmg">
<a href="{% url 'server_run:server-run_detail' server_run.uuid %}">
<img style='height:30px ' alt="" src="https://img.shields.io/endpoint.svg?style=for-the-badge&amp;url={{request.scheme}}://{{request.get_host}}{% url 'apiv1server:api_server-run-shield' server_run.uuid %}">
</a>
</span>
</td> {% endcomment %}
</tr>
{% endspaceless %}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<td>
{% if last_run %}
<span display="block" class="common__BadgeWrapper-sc-16zh6vt-3 fagfmg">
<a href="{% url 'server_run:server-run_list' scenario.uuid environment.uuid %}">
<a href="{% url 'server_run:server-run_latest' scenario.uuid environment.uuid %}">
<img style="height:30px" alt="" src="https://img.shields.io/endpoint.svg?style=for-the-badge&amp;url={{request.scheme}}://{{request.get_host}}{% url 'apiv1server:latest-badge' environment.uuid %}">
</a>
</span>
Expand Down
32 changes: 32 additions & 0 deletions src/vng/servervalidation/tests/tests_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions src/vng/servervalidation/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
path('<uuid:uuid>/', views.ServerRunOutputUuid.as_view(), name='server-run_detail'),
path('<int:api_id>/', views.TestScenarioList.as_view(), name='test-scenario_list'),
path('<uuid:scenario_uuid>/<uuid:env_uuid>/', views.ServerRunList.as_view(), name='server-run_list'),
path('<uuid:scenario_uuid>/<uuid:env_uuid>/latest/', views.LatestRunView.as_view(), name='server-run_latest'),
# path('', views.ServerRunList.as_view(), name='server-run_list'),
]
14 changes: 14 additions & 0 deletions src/vng/servervalidation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()