All of lore.kernel.org
 help / color / mirror / Atom feed
* [review-request][PATCH] toastergui: Add tests for xhr_importlayer
@ 2015-08-05 12:57 Sujith H
  2015-08-06 14:42 ` Michael Wood
  0 siblings, 1 reply; 3+ messages in thread
From: Sujith H @ 2015-08-05 12:57 UTC (permalink / raw)
  To: toaster

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@gmail.com>
Signed-off-by: Sujith Haridasan <Sujith_Haridasan@mentor.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 77e80fe..c4db145 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -75,3 +75,21 @@ 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):
+        data = {'vcs_url' : "/home/sujith/MEL/toaster_work/meta-oe" ,
+                'name' : "base-layer", 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
+                'project_id': 1, 'dir_path' : "/home/sujith/MEL/toaster_work/meta-oe/meta-oe"}
+        result  = self.client.post(reverse('xhr_importlayer'), data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+        self.assertEqual(result.status_code,200)
+        self.assertTrue("hint-layer-exists-with-different-url" in result.content)
+        data['name'] = "meta-oe"
+        result  = self.client.post(reverse('xhr_importlayer'), data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+        self.assertTrue('"error": "ok"' in result.content)
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [review-request][PATCH] toastergui: Add tests for xhr_importlayer
  2015-08-05 12:57 [review-request][PATCH] toastergui: Add tests for xhr_importlayer Sujith H
@ 2015-08-06 14:42 ` Michael Wood
  2015-08-06 15:01   ` sujith h
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Wood @ 2015-08-06 14:42 UTC (permalink / raw)
  To: toaster

Couple of comments inline:

On 05/08/15 13:57, Sujith H 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@gmail.com>
> Signed-off-by: Sujith Haridasan <Sujith_Haridasan@mentor.com>
> ---
>   bitbake/lib/toaster/toastergui/tests.py | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
>
> diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
> index 77e80fe..c4db145 100644
> --- a/bitbake/lib/toaster/toastergui/tests.py
> +++ b/bitbake/lib/toaster/toastergui/tests.py
> @@ -75,3 +75,21 @@ 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):
> +        data = {'vcs_url' : "/home/sujith/MEL/toaster_work/meta-oe" ,
Could you use a faked vcs_url value, e.g. "git://git.example.com/test"

> +                'name' : "base-layer", 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
> +                'project_id': 1, 'dir_path' : "/home/sujith/MEL/toaster_work/meta-oe/meta-oe"}
Same with this one, dir_path can be "/path/in/repository"
> +        result  = self.client.post(reverse('xhr_importlayer'), data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
I don't think HTTP_X_REQUESTED_WITH really needs setting, the default 
should be fine.
> +        self.assertEqual(result.status_code,200)
> +        self.assertTrue("hint-layer-exists-with-different-url" in result.content)
> +        data['name'] = "meta-oe"
> +        result  = self.client.post(reverse('xhr_importlayer'), data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
> +        self.assertTrue('"error": "ok"' in result.content)
Some new lines between the logical parts in the test would be good.

It would be great to cover these two conditions as well:

{"error": "Missing parameters; requires vcs_url, name, git_ref and 
project_id"}
{"error": "Invalid character <"}

Thanks,

Michael


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [review-request][PATCH] toastergui: Add tests for xhr_importlayer
  2015-08-06 14:42 ` Michael Wood
@ 2015-08-06 15:01   ` sujith h
  0 siblings, 0 replies; 3+ messages in thread
From: sujith h @ 2015-08-06 15:01 UTC (permalink / raw)
  To: Michael Wood; +Cc: toaster

[-- Attachment #1: Type: text/plain, Size: 3282 bytes --]

On Thu, Aug 6, 2015 at 8:12 PM, Michael Wood <michael.g.wood@intel.com>
wrote:

> Couple of comments inline:
>
>
> On 05/08/15 13:57, Sujith H 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@gmail.com>
>> Signed-off-by: Sujith Haridasan <Sujith_Haridasan@mentor.com>
>> ---
>>   bitbake/lib/toaster/toastergui/tests.py | 18 ++++++++++++++++++
>>   1 file changed, 18 insertions(+)
>>
>> diff --git a/bitbake/lib/toaster/toastergui/tests.py
>> b/bitbake/lib/toaster/toastergui/tests.py
>> index 77e80fe..c4db145 100644
>> --- a/bitbake/lib/toaster/toastergui/tests.py
>> +++ b/bitbake/lib/toaster/toastergui/tests.py
>> @@ -75,3 +75,21 @@ 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):
>> +        data = {'vcs_url' : "/home/sujith/MEL/toaster_work/meta-oe" ,
>>
> Could you use a faked vcs_url value, e.g. "git://git.example.com/test"
>
> +                'name' : "base-layer", 'git_ref':
>> "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
>> +                'project_id': 1, 'dir_path' :
>> "/home/sujith/MEL/toaster_work/meta-oe/meta-oe"}
>>
> Same with this one, dir_path can be "/path/in/repository"
>
>> +        result  = self.client.post(reverse('xhr_importlayer'), data,
>> HTTP_X_REQUESTED_WITH='XMLHttpRequest')
>>
> I don't think HTTP_X_REQUESTED_WITH really needs setting, the default
> should be fine.
>
So if I understand correctly I can remove HTTP_X_REQUESTED_WITH from the
argument list, right?

> +        self.assertEqual(result.status_code,200)
>> +        self.assertTrue("hint-layer-exists-with-different-url" in
>> result.content)
>> +        data['name'] = "meta-oe"
>> +        result  = self.client.post(reverse('xhr_importlayer'), data,
>> HTTP_X_REQUESTED_WITH='XMLHttpRequest')
>> +        self.assertTrue('"error": "ok"' in result.content)
>>
> Some new lines between the logical parts in the test would be good.
>
> It would be great to cover these two conditions as well:
>
> {"error": "Missing parameters; requires vcs_url, name, git_ref and
> project_id"}
> {"error": "Invalid character <"}
>

Sure will incorporate the changes mentioned. Thanks for the feed back.

>
> Thanks,
>
> Michael
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
സുജിത് ഹരിദാസന്
Bangalore
<Project>Contributor to KDE project
http://fci.wikia.com/wiki/Anti-DRM-Campaign
<Blog> http://sujithh.info

[-- Attachment #2: Type: text/html, Size: 5484 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-06 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 12:57 [review-request][PATCH] toastergui: Add tests for xhr_importlayer Sujith H
2015-08-06 14:42 ` Michael Wood
2015-08-06 15:01   ` sujith h

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.