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
10"""
11A small example test demonstrating the basics of writing a test with
12Toaster's SeleniumTestCase; this just fetches the Toaster home page
13and checks it has the word "Toaster" in the brand link
14
15New test files should follow this structure, should be named "test_*.py",
16and should be in the same directory as this sample.
17"""
18
19from django.urls import reverse
20from tests.browser.selenium_helpers import SeleniumTestCase
21
22class TestSample(SeleniumTestCase):
23    """ Test landing page shows the Toaster brand """
24
25    def test_landing_page_has_brand(self):
26        url = reverse('landing')
27        self.get(url)
28        brand_link = self.find('.toaster-navbar-brand a.brand')
29        self.assertEqual(brand_link.text.strip(), 'Toaster')
30
31    def test_no_builds_message(self):
32        """ Test that a message is shown when there are no builds """
33        url = reverse('all-builds')
34        self.get(url)
35        self.wait_until_visible('#empty-state-allbuildstable')  # wait for the empty state div to appear
36        div_msg = self.find('#empty-state-allbuildstable .alert-info')
37
38        msg = 'Sorry - no data found'
39        self.assertEqual(div_msg.text, msg)
40