Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 63045E0034B; Mon, 10 Aug 2015 02:03:24 -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) * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.192.173 listed in list.dnswl.org] * -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 Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 33497E00306 for ; Mon, 10 Aug 2015 02:03:19 -0700 (PDT) Received: by pdrh1 with SMTP id h1so51315851pdr.0 for ; Mon, 10 Aug 2015 02:03:19 -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=lEqZM4OzA9c4sKcVl23FTcTN96sRvJAyXmazixdHewo=; b=u1DdJI3GnsBsMGpvSmA7ojO9B0lK2ksHyFlg78l7VrIaYdP/hEcphu0c9U2qEqxhJ2 6/bzIHxdo8yxWPImsqdvfCSAWZiQaw8MTH7C2UvnwE7Q4kOcfxmLWbwxDPW9yKKAjpMh 9M7Nxk31Nq/jWreUlwMs8W2Sr2buPnQgRc/1E5bmjFHOQB5pT2Eywxm6GyiZQm6NnpMs ZpcQlCmDld+GejYvAltKNJ2goMSRnkzO9iwu0yQONlF2CkvSI//r+qKrXU8FOqqvg5zn eRNaV1Tf3lqCsmIhQtw/x3bawgtY0AYoxrgnJSXVoJnsuimB1xqbzClBm4l2qmeAClok 5OXQ== X-Received: by 10.70.14.36 with SMTP id m4mr41943835pdc.117.1439197398955; Mon, 10 Aug 2015 02:03:18 -0700 (PDT) Received: from kdekidd0.inp.mentorg.com ([139.181.35.34]) by smtp.gmail.com with ESMTPSA id qg4sm19099845pdb.46.2015.08.10.02.03.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Aug 2015 02:03:18 -0700 (PDT) From: Sujith H To: toaster@yoctoproject.org Date: Mon, 10 Aug 2015 14:33:10 +0530 Message-Id: <1439197390-9570-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: Mon, 10 Aug 2015 09:03:24 -0000 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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 93a85ac..2986e57 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py @@ -148,3 +148,35 @@ class ViewTests(TestCase): # After "typeing" the alpabet we should have result true # from each of the urls self.assertTrue(results) + +class XHRImportLayerTestCase(ViewTests): + """ Tests to verify xhr_importlayer API""" + def setUp(self): + super(XHRImportLayerTestCase, self).setUp() + + def test_import(self): + """Tests to verify import layer already exist, if the imported layer is ok, response + for empty data, response for html tag in data""" + #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