[Toaster] [review-request][PATCH][v2] toastergui: Add tests for xhr_importlayer

sujith h sujith.h at gmail.com
Mon Aug 10 02:06:19 PDT 2015


Hi Ed,

I have rebased the patch on branch d/toaster/fix-toastergui-tests.

I ran : pylint --load-plugins pylint_django toastergui/tests.py; and got a
score of 10.

Let me know if more changes are required.

Thanks,
Sujith H

On Mon, Aug 10, 2015 at 2:33 PM, Sujith H <sujith.h at gmail.com> wrote:

> 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 <sujith.h at gmail.com>
> Signed-off-by: Sujith Haridasan <Sujith_Haridasan at mentor.com>
> ---
>  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
>
>


-- 
സുജിത് ഹരിദാസന്
Bangalore
<Project>Contributor to KDE project
http://fci.wikia.com/wiki/Anti-DRM-Campaign
<Blog> http://sujithh.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/toaster/attachments/20150810/6b969f11/attachment.html>


More information about the toaster mailing list