Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id AA2F9E00A01; Thu, 6 Aug 2015 08:41:57 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (sujith.h[at]gmail.com) * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's * domain * 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 * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.223.171 listed in list.dnswl.org] Received: from mail-io0-f171.google.com (mail-io0-f171.google.com [209.85.223.171]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id EFA2AE009B8 for ; Thu, 6 Aug 2015 08:41:53 -0700 (PDT) Received: by ioii16 with SMTP id i16so85186403ioi.0 for ; Thu, 06 Aug 2015 08:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=aeiXxmejrQlkyHglhjf5oNRbnuMSXGxRIFb7dWhuFg8=; b=pCh9kYFrAI5rYvTF1VQLc5zpObQJ168/2eJgn7TuDlFzbvYOyOpEhFceZJAqX1clXs 7g14po5kthcUZMQvE7agZXYTBsu7dHsV6a0NBXRAbIzMcS93peIipH/VNpEXWCATrMaE SqaAjW7ShY25njGFjQYAx5VJPFEIATXuUi6/1w2mQfImnqvf8xBLc3qFhFy8fMNlILV5 3rectLnnzc72eG2LzbKYMP3uONxzBrV+MimJNPLO2tZWa+eDMOpuhnGDZljOr2ZybQyf a0M0qQ9TdYs9j4YUxAGjkJlj1BGR/vxjka4Inem2wsAyU4FvHU5i/DRlEi6TkcnE/Pot oAGA== X-Received: by 10.107.12.104 with SMTP id w101mr3359355ioi.110.1438875713361; Thu, 06 Aug 2015 08:41:53 -0700 (PDT) Received: from kdekidd0.inp.mentorg.com ([139.181.35.34]) by smtp.gmail.com with ESMTPSA id h32sm4734119iod.29.2015.08.06.08.41.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Aug 2015 08:41:52 -0700 (PDT) From: Sujith H To: toaster@yoctoproject.org Date: Thu, 6 Aug 2015 21:11:28 +0530 Message-Id: <1438875688-16222-1-git-send-email-sujith.h@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [review-request][PATCH][v2] toastergui: Add tests for xhr_importlayer 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: Thu, 06 Aug 2015 15:41:57 -0000 From: Sujith Haridasan Inorder to make sure if layer name which we import is already available in toaster database, a test case has been included. This would help user to identify if layer name which has been provided in the import layer web page already exists or not. Signed-off-by: Sujith Haridasan Signed-off-by: Sujith Haridasan --- bitbake/lib/toaster/toastergui/tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 77e80fe..9e444ae 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py @@ -75,3 +75,34 @@ class XHRDataTypeAheadTestCase(ProvisionedLayersProjectTestCase): self.assertTrue(len(data["list"]) > 0) self.assertTrue(XHRDataTypeAheadTestCase.LAYER_NAME in map(lambda x: x["name"], data["list"])) + + +class XHRImportLayerTestCase(ProvisionedLayersProjectTestCase): + + def setUp(self): + super(XHRImportLayerTestCase, self).setUp() + self.assertTrue(self.lv in self.project.compatible_layerversions()) + + def test_import(self): + #Test for importing an already existing layer + data = {'vcs_url' : "git://git.example.com/test" , + 'name' : "base-layer", 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce", + 'project_id': 1, 'dir_path' : "/path/in/repository"} + result = self.client.post(reverse('xhr_importlayer'), data) + self.assertEqual(result.status_code,200) + self.assertTrue("hint-layer-exists-with-different-url" in result.content) + + #Test to verify import of a layer successful + data['name'] = "meta-oe" + result = self.client.post(reverse('xhr_importlayer'), data) + self.assertTrue('"error": "ok"' in result.content) + + #Test for html tag in the data + data['<'] = "testing html tag" + result = self.client.post(reverse('xhr_importlayer'), data) + self.assertTrue('"error": "Invalid character <"' in result.content) + + #Empty data passed + data = {} + result = self.client.post(reverse('xhr_importlayer'), data) + self.assertTrue('"error": "Missing parameters; requires vcs_url, name, git_ref and project_id"' in result.content) -- 1.9.1