Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 939FBE006D3; Mon, 9 May 2016 08:27:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [74.125.82.46 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 20D3AE005BB for ; Mon, 9 May 2016 08:27:39 -0700 (PDT) Received: by mail-wm0-f46.google.com with SMTP id a17so193673628wme.0 for ; Mon, 09 May 2016 08:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eUJ9vQyKwXNUUIgBwVYQgOJF6LHRrjasQtmzAbeEHac=; b=j+o1+jVrAuPBTEgYbt7npdByUMk/8evcCWLbBPERSQAQsMGuAXgkQskd4m/DFa2Vnm VLVsmxwTGkMpVrOpN2lFGABvzLGuiWoRFI24L+hd0F4KPv+Db36vF66xA97XOKX3djdj SRvzWNI1FowuiVvSeLuPbPrZdkmZRh6zk3XBrUeAp8ZtPUx87j0lQTsVrXrmXN0d5I7H xrZAQf1OMAa7w2KIrPvIS61n+V+PlPWIj/H96riJvsGNTc1zcg9/1Fm/Y98vftpCYT5V 8VM4NxTyOFp2lHXUTFAXK2I9Xs3eb2QEJflDmFTrGfqS0+sj952MWc7eTyp5G41UQbYa 8kDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eUJ9vQyKwXNUUIgBwVYQgOJF6LHRrjasQtmzAbeEHac=; b=l7y166sKUZrZGf6wwNVvm6ygOFYezLSD0Zw4nYR6heYh9nILP/uBr0l877UQJB/ZMT 02Z9361Tn8wKBiI9EQ4ng2a2itRdKZ7o5/hlsrBtDlXGlN/HfZQVrXtfVKxPDzWqK0LO LXuQ6Hg2Zq3jb0jX0tuMrA7sRK1uL5qo7gWi+RQ6UaqnRTTqNJAtkleP9fBgBiPuQTv1 ytdPsnCC9XcWp58nH2SQqflSg+Cs0UqX00H8yL6xPeuqILe+McaoNC2gYdsr32W9KIOq IXhHTYtZTLMbkcXTaUD/8zGLor7R3bR4MyyILx6Iw7yDirAeoD2cTOrPjxonIhqFMNeH UFtQ== X-Gm-Message-State: AOPr4FV8EaHK3ChYdF09amCzhsyiDMNvbJoAGedTcUNLGj/A1b2cuZiaGgq87eiadGh0VDYY X-Received: by 10.194.231.196 with SMTP id ti4mr37278694wjc.41.1462807658911; Mon, 09 May 2016 08:27:38 -0700 (PDT) Received: from orion.home (host109-151-244-175.range109-151.btcentralplus.com. [109.151.244.175]) by smtp.gmail.com with ESMTPSA id b15sm25192732wmd.1.2016.05.09.08.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 May 2016 08:27:38 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Mon, 9 May 2016 16:27:31 +0100 Message-Id: <1462807651-16627-6-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462807651-16627-1-git-send-email-michael.g.wood@intel.com> References: <1462807651-16627-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 5/5] toaster: tests browser Add test for creating a project X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2016 15:27:41 -0000 Add browser tests for creating a project and test validation of duplicate project names. Signed-off-by: Michael Wood --- .../toaster/tests/browser/test_new_project_page.py | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 bitbake/lib/toaster/tests/browser/test_new_project_page.py diff --git a/bitbake/lib/toaster/tests/browser/test_new_project_page.py b/bitbake/lib/toaster/tests/browser/test_new_project_page.py new file mode 100644 index 0000000..b9358ab --- /dev/null +++ b/bitbake/lib/toaster/tests/browser/test_new_project_page.py @@ -0,0 +1,109 @@ +#! /usr/bin/env python +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# BitBake Toaster Implementation +# +# Copyright (C) 2013-2016 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from django.core.urlresolvers import reverse +from tests.browser.selenium_helpers import SeleniumTestCase +from selenium.webdriver.support.ui import Select + +from orm.models import Project, Release, BitbakeVersion + + +class TestNewProjectPage(SeleniumTestCase): + """ Test project data at /project/X/ is displayed correctly """ + + def setUp(self): + bitbake, c = BitbakeVersion.objects.get_or_create( + name="master", + giturl="git://master", + branch="master", + dirpath="master") + + release, c = Release.objects.get_or_create(name="msater", + description="master" + "release", + branch_name="master", + helptext="latest", + bitbake_version=bitbake) + + self.release, c = Release.objects.get_or_create( + name="msater2", + description="master2" + "release2", + branch_name="master2", + helptext="latest2", + bitbake_version=bitbake) + + def test_create_new_project(self): + """ Test creating a project """ + + project_name = "masterproject" + + url = reverse('newproject') + self.get(url) + + self.enter_text('#new-project-name', project_name) + + select = Select(self.find('#projectversion')) + select.select_by_value(str(self.release.pk)) + + self.click("#create-project-button") + + # We should get redirected to the new project's page with the + # notification at the top + element = self.wait_until_visible('#project-created-notification') + + self.assertTrue(project_name in element.text, + "New project name not in new project notification") + + self.assertTrue(Project.objects.filter(name=project_name).count(), + "New project not found in database") + + def test_new_duplicates_project_name(self): + """ + Should not be able to create a new project whose name is the same + as an existing project + """ + + project_name = "dupproject" + + Project.objects.create_project(name=project_name, + release=self.release) + + url = reverse('newproject') + self.get(url) + + self.enter_text('#new-project-name', project_name) + + select = Select(self.find('#projectversion')) + select.select_by_value(str(self.release.pk)) + + element = self.wait_until_visible('#hint-error-project-name') + + self.assertTrue(("Project names must be unique" in element.text), + "Did not find unqiue project name error message") + + # Try and click it anyway, if it submits we'll have a new project in + # the db and assert then + self.click("#create-project-button") + + self.assertTrue( + (Project.objects.filter(name=project_name).count() == 1), + "New project not found in database") -- 2.7.4