diff options
| -rw-r--r-- | bitbake/lib/toaster/toastergui/tests.py | 91 | ||||
| -rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 5 | ||||
| -rw-r--r-- | bitbake/toaster-requirements.txt | 1 |
3 files changed, 91 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 1a8b4787dd..4d1549b0a9 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py | |||
| @@ -24,10 +24,11 @@ | |||
| 24 | from django.test import TestCase | 24 | from django.test import TestCase |
| 25 | from django.core.urlresolvers import reverse | 25 | from django.core.urlresolvers import reverse |
| 26 | from django.utils import timezone | 26 | from django.utils import timezone |
| 27 | from orm.models import Project, Release, BitbakeVersion, Build | 27 | from orm.models import Project, Release, BitbakeVersion, ProjectTarget |
| 28 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer | 28 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build |
| 29 | from orm.models import Layer_Version, Recipe, Machine, ProjectLayer | 29 | from orm.models import Layer_Version, Recipe, Machine, ProjectLayer |
| 30 | import json | 30 | import json |
| 31 | from bs4 import BeautifulSoup | ||
| 31 | 32 | ||
| 32 | PROJECT_NAME = "test project" | 33 | PROJECT_NAME = "test project" |
| 33 | 34 | ||
| @@ -41,7 +42,6 @@ class ViewTests(TestCase): | |||
| 41 | bitbake_version=bbv) | 42 | bitbake_version=bbv) |
| 42 | self.project = Project.objects.create_project(name=PROJECT_NAME, | 43 | self.project = Project.objects.create_project(name=PROJECT_NAME, |
| 43 | release=release) | 44 | release=release) |
| 44 | |||
| 45 | layersrc = LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED) | 45 | layersrc = LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED) |
| 46 | self.priority = ReleaseLayerSourcePriority.objects.create(release=release, | 46 | self.priority = ReleaseLayerSourcePriority.objects.create(release=release, |
| 47 | layer_source=layersrc) | 47 | layer_source=layersrc) |
| @@ -292,3 +292,88 @@ class ProjectsPageTests(TestCase): | |||
| 292 | 'should be a project row in the page') | 292 | 'should be a project row in the page') |
| 293 | self.assertTrue(self.PROJECT_NAME in response.content, | 293 | self.assertTrue(self.PROJECT_NAME in response.content, |
| 294 | 'default project "cli builds" should be in page') | 294 | 'default project "cli builds" should be in page') |
| 295 | |||
| 296 | class ProjectBuildsDisplayTest(TestCase): | ||
| 297 | """ Test data at /project/X/builds is displayed correctly """ | ||
| 298 | |||
| 299 | def setUp(self): | ||
| 300 | bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/", | ||
| 301 | branch="master", dirpath="") | ||
| 302 | release = Release.objects.create(name="release1", | ||
| 303 | bitbake_version=bbv) | ||
| 304 | self.project1 = Project.objects.create_project(name=PROJECT_NAME, | ||
| 305 | release=release) | ||
| 306 | self.project2 = Project.objects.create_project(name=PROJECT_NAME, | ||
| 307 | release=release) | ||
| 308 | |||
| 309 | # parameters for builds to associate with the projects | ||
| 310 | now = timezone.now() | ||
| 311 | |||
| 312 | self.project1_build_success = { | ||
| 313 | "project": self.project1, | ||
| 314 | "started_on": now, | ||
| 315 | "completed_on": now, | ||
| 316 | "outcome": Build.SUCCEEDED | ||
| 317 | } | ||
| 318 | |||
| 319 | self.project1_build_in_progress = { | ||
| 320 | "project": self.project1, | ||
| 321 | "started_on": now, | ||
| 322 | "completed_on": now, | ||
| 323 | "outcome": Build.IN_PROGRESS | ||
| 324 | } | ||
| 325 | |||
| 326 | self.project2_build_success = { | ||
| 327 | "project": self.project2, | ||
| 328 | "started_on": now, | ||
| 329 | "completed_on": now, | ||
| 330 | "outcome": Build.SUCCEEDED | ||
| 331 | } | ||
| 332 | |||
| 333 | self.project2_build_in_progress = { | ||
| 334 | "project": self.project2, | ||
| 335 | "started_on": now, | ||
| 336 | "completed_on": now, | ||
| 337 | "outcome": Build.IN_PROGRESS | ||
| 338 | } | ||
| 339 | |||
| 340 | def _get_rows_for_project(self, project_id): | ||
| 341 | url = reverse("projectbuilds", args=(project_id,)) | ||
| 342 | response = self.client.get(url, follow=True) | ||
| 343 | soup = BeautifulSoup(response.content) | ||
| 344 | return soup.select('tr[class="data"]') | ||
| 345 | |||
| 346 | def test_show_builds_for_project(self): | ||
| 347 | """ Builds for a project should be displayed """ | ||
| 348 | build1a = Build.objects.create(**self.project1_build_success) | ||
| 349 | build1b = Build.objects.create(**self.project1_build_success) | ||
| 350 | build_rows = self._get_rows_for_project(self.project1.id) | ||
| 351 | self.assertEqual(len(build_rows), 2) | ||
| 352 | |||
| 353 | def test_show_builds_for_project_only(self): | ||
| 354 | """ Builds for other projects should be excluded """ | ||
| 355 | build1a = Build.objects.create(**self.project1_build_success) | ||
| 356 | build1b = Build.objects.create(**self.project1_build_success) | ||
| 357 | build1c = Build.objects.create(**self.project1_build_success) | ||
| 358 | |||
| 359 | # shouldn't see these two | ||
| 360 | build2a = Build.objects.create(**self.project2_build_success) | ||
| 361 | build2b = Build.objects.create(**self.project2_build_in_progress) | ||
| 362 | |||
| 363 | build_rows = self._get_rows_for_project(self.project1.id) | ||
| 364 | self.assertEqual(len(build_rows), 3) | ||
| 365 | |||
| 366 | def test_show_builds_exclude_in_progress(self): | ||
| 367 | """ "in progress" builds should not be shown """ | ||
| 368 | build1a = Build.objects.create(**self.project1_build_success) | ||
| 369 | build1b = Build.objects.create(**self.project1_build_success) | ||
| 370 | |||
| 371 | # shouldn't see this one | ||
| 372 | build1c = Build.objects.create(**self.project1_build_in_progress) | ||
| 373 | |||
| 374 | # shouldn't see these two either, as they belong to a different project | ||
| 375 | build2a = Build.objects.create(**self.project2_build_success) | ||
| 376 | build2b = Build.objects.create(**self.project2_build_in_progress) | ||
| 377 | |||
| 378 | build_rows = self._get_rows_for_project(self.project1.id) | ||
| 379 | self.assertEqual(len(build_rows), 2) \ No newline at end of file | ||
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index d9802f01b8..8689a1251e 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
| @@ -40,7 +40,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | |||
| 40 | from django.http import HttpResponseBadRequest, HttpResponseNotFound | 40 | from django.http import HttpResponseBadRequest, HttpResponseNotFound |
| 41 | from django.utils import timezone | 41 | from django.utils import timezone |
| 42 | from django.utils.html import escape | 42 | from django.utils.html import escape |
| 43 | from datetime import timedelta, datetime, date | 43 | from datetime import timedelta, datetime |
| 44 | from django.utils import formats | 44 | from django.utils import formats |
| 45 | from toastergui.templatetags.projecttags import json as jsonfilter | 45 | from toastergui.templatetags.projecttags import json as jsonfilter |
| 46 | import json | 46 | import json |
| @@ -442,8 +442,7 @@ def _modify_date_range_filter(filter_string): | |||
| 442 | def _add_daterange_context(queryset_all, request, daterange_list): | 442 | def _add_daterange_context(queryset_all, request, daterange_list): |
| 443 | # calculate the exact begining of local today and yesterday | 443 | # calculate the exact begining of local today and yesterday |
| 444 | today_begin = timezone.localtime(timezone.now()) | 444 | today_begin = timezone.localtime(timezone.now()) |
| 445 | today_begin = date(today_begin.year,today_begin.month,today_begin.day) | 445 | yesterday_begin = today_begin - timedelta(days=1) |
| 446 | yesterday_begin = today_begin-timedelta(days=1) | ||
| 447 | # add daterange persistent | 446 | # add daterange persistent |
| 448 | context_date = {} | 447 | context_date = {} |
| 449 | context_date['last_date_from'] = request.GET.get('last_date_from',timezone.localtime(timezone.now()).strftime("%d/%m/%Y")) | 448 | context_date['last_date_from'] = request.GET.get('last_date_from',timezone.localtime(timezone.now()).strftime("%d/%m/%Y")) |
diff --git a/bitbake/toaster-requirements.txt b/bitbake/toaster-requirements.txt index 1d92d5e3a7..c4a2221553 100644 --- a/bitbake/toaster-requirements.txt +++ b/bitbake/toaster-requirements.txt | |||
| @@ -3,3 +3,4 @@ South==0.8.4 | |||
| 3 | argparse==1.2.1 | 3 | argparse==1.2.1 |
| 4 | wsgiref==0.1.2 | 4 | wsgiref==0.1.2 |
| 5 | filemagic==1.6 | 5 | filemagic==1.6 |
| 6 | beautifulsoup4>=4.4.0 | ||
