xref: /openbmc/openbmc/poky/bitbake/lib/toaster/tests/browser/test_project_page.py (revision 82c905dc58a36aeae40b1b273a12f63fb1973cf4)
1#! /usr/bin/env python3
2#
3# BitBake Toaster Implementation
4#
5# Copyright (C) 2013-2016 Intel Corporation
6#
7# SPDX-License-Identifier: GPL-2.0-only
8#
9
10from django.urls import reverse
11from django.utils import timezone
12from tests.browser.selenium_helpers import SeleniumTestCase
13
14from orm.models import Build, Project
15
16class TestProjectPage(SeleniumTestCase):
17    """ Test project data at /project/X/ is displayed correctly """
18
19    CLI_BUILDS_PROJECT_NAME = 'Command line builds'
20
21    def test_cli_builds_in_progress(self):
22        """
23        In progress builds should not cause an error to be thrown
24        when navigating to "command line builds" project page;
25        see https://bugzilla.yoctoproject.org/show_bug.cgi?id=8277
26        """
27
28        # add the "command line builds" default project; this mirrors what
29        # we do with get_or_create_default_project()
30        default_project = Project.objects.create_project(self.CLI_BUILDS_PROJECT_NAME, None)
31        default_project.is_default = True
32        default_project.save()
33
34        # add an "in progress" build for the default project
35        now = timezone.now()
36        Build.objects.create(project=default_project,
37                             started_on=now,
38                             completed_on=now,
39                             outcome=Build.IN_PROGRESS)
40
41        # navigate to the project page for the default project
42        url = reverse("project", args=(default_project.id,))
43        self.get(url)
44
45        # check that we get a project page with the correct heading
46        project_name = self.find('.project-name').text.strip()
47        self.assertEqual(project_name, self.CLI_BUILDS_PROJECT_NAME)
48