All of lore.kernel.org
 help / color / mirror / Atom feed
* [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests
@ 2015-08-06 10:15 Ed Bartosh
  2015-08-06 10:15 ` [PATCH 1/9] toaster: fix test_get_json_call_returns_json test Ed Bartosh
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

This patchset contains fixes and code cleanups for toastergui tests.
Some tests were completely rewritten.

Now all 3 test cases are passed and pylint score is 10.

The following changes since commit a8b723498c9a7106210db140452886894494b4d6:

  bitbake: cooker: Resolve file monitoring race issues when using memres bitbake (2015-08-03 07:36:25 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib ed/toaster/fix-toastergui-tests
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/toaster/fix-toastergui-tests

Ed Bartosh (9):
  toaster: fix test_get_json_call_returns_json test
  toaster: fix test_xhr_datatypeahead_layer test
  toaster: wrap long lines
  toaster: get rid of AllProjectsViewTestCase
  toaster: put all test cases into one class
  toaster: get rid of class attribute LAYER_NAME
  toaster: remove unused import
  toaster: add header and docsting
  toaster: don't catch json.load exceptions

 bitbake/lib/toaster/toastergui/tests.py | 119 +++++++++++++++++++-------------
 1 file changed, 70 insertions(+), 49 deletions(-)

--
Regards,
Ed


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

* [PATCH 1/9] toaster: fix test_get_json_call_returns_json test
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 2/9] toaster: fix test_xhr_datatypeahead_layer test Ed Bartosh
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

This test case used wrong field name. Fixed by renaming field 'lists' -> 'rows'.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 77e80fe..e3bbd62 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -34,13 +34,13 @@ class AllProjectsViewTestCase(ProvisionedProjectTestCase):
 
         self.assertTrue("error" in data)
         self.assertEqual(data["error"], "ok")
-        self.assertTrue("list" in data)
+        self.assertTrue("rows" in data)
 
-        self.assertTrue(AllProjectsViewTestCase.TEST_PROJECT_NAME in map(lambda x: x["name"], data["list"]))
-        self.assertTrue("id" in data["list"][0])
-        self.assertTrue("projectLayersUrl" in data["list"][0])
-        self.assertTrue("projectPageUrl" in data["list"][0])
-        self.assertTrue("projectBuildsUrl" in data["list"][0])
+        self.assertTrue(AllProjectsViewTestCase.TEST_PROJECT_NAME in map(lambda x: x["name"], data["rows"]))
+        self.assertTrue("id" in data["rows"][0])
+        self.assertTrue("projectLayersUrl" in data["rows"][0])
+        self.assertTrue("projectPageUrl" in data["rows"][0])
+        self.assertTrue("projectBuildsUrl" in data["rows"][0])
 
 class ProvisionedLayersProjectTestCase(ProvisionedProjectTestCase):
     LAYER_NAME = "base-layer"
-- 
2.1.4



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

* [PATCH 2/9] toaster: fix test_xhr_datatypeahead_layer test
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
  2015-08-06 10:15 ` [PATCH 1/9] toaster: fix test_get_json_call_returns_json test Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 3/9] toaster: wrap long lines Ed Bartosh
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

The test was expecting data returned from the ReST call, but it was
not valid expectation as database is empty. It also used wrong
field name 'list' instead of 'rows'.

Fixed by adjusting assert to expect empty response.
Used correct field name 'rows' instead of 'list'.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index e3bbd62..f2403e8 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -59,7 +59,7 @@ class XHRDataTypeAheadTestCase(ProvisionedLayersProjectTestCase):
         self.assertTrue(self.lv in self.project.compatible_layerversions())
 
     def test_xhr_datatypeahead_layer(self):
-        response = self.client.get(reverse('xhr_datatypeahead', args=(self.project.id,)), {"type": "layerdeps"})
+        response = self.client.get(reverse('xhr_datatypeahead', args=(self.project.id,)), {"type": "versionlayers"})
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('application/json'))
 
@@ -71,7 +71,5 @@ class XHRDataTypeAheadTestCase(ProvisionedLayersProjectTestCase):
 
         self.assertTrue("error" in data)
         self.assertEqual(data["error"], "ok")
-        self.assertTrue("list" in data)
-        self.assertTrue(len(data["list"]) > 0)
-
-        self.assertTrue(XHRDataTypeAheadTestCase.LAYER_NAME in map(lambda x: x["name"], data["list"]))
+        self.assertTrue("rows" in data)
+        self.assertEqual(len(data["rows"]), 0)
-- 
2.1.4



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

* [PATCH 3/9] toaster: wrap long lines
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
  2015-08-06 10:15 ` [PATCH 1/9] toaster: fix test_get_json_call_returns_json test Ed Bartosh
  2015-08-06 10:15 ` [PATCH 2/9] toaster: fix test_xhr_datatypeahead_layer test Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 4/9] toaster: get rid of AllProjectsViewTestCase Ed Bartosh
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

Fixed pylint warning Line too long (line-too-long).

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 43 ++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index f2403e8..d4aacb3 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -1,15 +1,21 @@
 from django.test import TestCase
 from django.core.urlresolvers import reverse
 from orm.models import Project, Release, BitbakeVersion, Build
-from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Layer_Version
+from orm.models import ReleaseLayerSourcePriority, LayerSource
+from orm.models import  Layer, Layer_Version
+
+PROJECT_NAME = "test project"
 
 class ProvisionedProjectTestCase(TestCase):
-    TEST_PROJECT_NAME = "test project"
 
     def setUp(self):
-        self.bbv, created = BitbakeVersion.objects.get_or_create(name="test bbv", giturl="/tmp/", branch="master", dirpath="")
-        self.release, created = Release.objects.get_or_create(name="test release", bitbake_version = self.bbv)
-        self.project = Project.objects.create_project(name=AllProjectsViewTestCase.TEST_PROJECT_NAME, release=self.release)
+        self.bbv = BitbakeVersion.objects.create(\
+                       name="test bbv", giturl="/tmp/",
+                       branch="master", dirpath="")
+        self.release = Release.objects.create(\
+                           name="test release", bitbake_version=self.bbv)
+        self.project = Project.objects.create_project(name=PROJECT_NAME,
+                                                      release=self.release)
 
 
 class AllProjectsViewTestCase(ProvisionedProjectTestCase):
@@ -19,10 +25,11 @@ class AllProjectsViewTestCase(ProvisionedProjectTestCase):
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('text/html'))
         self.assertTemplateUsed(response, "projects.html")
-        self.assertTrue(AllProjectsViewTestCase.TEST_PROJECT_NAME in response.content)
+        self.assertTrue(PROJECT_NAME in response.content)
 
     def test_get_json_call_returns_json(self):
-        response = self.client.get(reverse('all-projects'), {"format": "json"}, follow=True)
+        url = reverse('all-projects')
+        response = self.client.get(url, {"format": "json"}, follow=True)
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('application/json'))
 
@@ -36,7 +43,7 @@ class AllProjectsViewTestCase(ProvisionedProjectTestCase):
         self.assertEqual(data["error"], "ok")
         self.assertTrue("rows" in data)
 
-        self.assertTrue(AllProjectsViewTestCase.TEST_PROJECT_NAME in map(lambda x: x["name"], data["rows"]))
+        self.assertTrue(PROJECT_NAME in [x["name"] for x in data["rows"]])
         self.assertTrue("id" in data["rows"][0])
         self.assertTrue("projectLayersUrl" in data["rows"][0])
         self.assertTrue("projectPageUrl" in data["rows"][0])
@@ -46,20 +53,28 @@ class ProvisionedLayersProjectTestCase(ProvisionedProjectTestCase):
     LAYER_NAME = "base-layer"
     def setUp(self):
         super(ProvisionedLayersProjectTestCase, self).setUp()
-        self.layersource, created = LayerSource.objects.get_or_create(sourcetype = LayerSource.TYPE_IMPORTED)
-        self.releaselayersourcepriority, created = ReleaseLayerSourcePriority.objects.get_or_create(release = self.release, layer_source = self.layersource)
-        self.layer, created = Layer.objects.get_or_create(name=XHRDataTypeAheadTestCase.LAYER_NAME, layer_source=self.layersource, vcs_url="/tmp/")
-        self.lv, created = Layer_Version.objects.get_or_create(layer = self.layer, project = self.project, layer_source=self.layersource, commit="master")
+        self.layersrc = LayerSource.objects.create(\
+                               sourcetype=LayerSource.TYPE_IMPORTED)
+        self.priority = ReleaseLayerSourcePriority.objects.create(\
+                               release=self.release,
+                               layer_source=self.layersrc)
+        self.layer = Layer.objects.create(\
+                         name=XHRDataTypeAheadTestCase.LAYER_NAME,
+                         layer_source=self.layersrc, vcs_url="/tmp/")
+        self.lver = Layer_Version.objects.create(\
+                        layer=self.layer, project=self.project,
+                        layer_source=self.layersrc, commit="master")
 
 
 class XHRDataTypeAheadTestCase(ProvisionedLayersProjectTestCase):
 
     def setUp(self):
         super(XHRDataTypeAheadTestCase, self).setUp()
-        self.assertTrue(self.lv in self.project.compatible_layerversions())
+        self.assertTrue(self.lver in self.project.compatible_layerversions())
 
     def test_xhr_datatypeahead_layer(self):
-        response = self.client.get(reverse('xhr_datatypeahead', args=(self.project.id,)), {"type": "versionlayers"})
+        url = reverse('xhr_datatypeahead', args=(self.project.id,))
+        response = self.client.get(url, {"type": "versionlayers"})
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('application/json'))
 
-- 
2.1.4



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

* [PATCH 4/9] toaster: get rid of AllProjectsViewTestCase
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
                   ` (2 preceding siblings ...)
  2015-08-06 10:15 ` [PATCH 3/9] toaster: wrap long lines Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 5/9] toaster: put all test cases into one class Ed Bartosh
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

Removed AllProjectsViewTestCase class as it had one method 'setUp'
and used as a parent for another class AllProjectsViewTestCase.

Moved setUp method to AllProjectsViewTestCase.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index d4aacb3..bba6f37 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -6,7 +6,7 @@ from orm.models import  Layer, Layer_Version
 
 PROJECT_NAME = "test project"
 
-class ProvisionedProjectTestCase(TestCase):
+class AllProjectsViewTestCase(TestCase):
 
     def setUp(self):
         self.bbv = BitbakeVersion.objects.create(\
@@ -17,9 +17,6 @@ class ProvisionedProjectTestCase(TestCase):
         self.project = Project.objects.create_project(name=PROJECT_NAME,
                                                       release=self.release)
 
-
-class AllProjectsViewTestCase(ProvisionedProjectTestCase):
-
     def test_get_base_call_returns_html(self):
         response = self.client.get(reverse('all-projects'), follow=True)
         self.assertEqual(response.status_code, 200)
-- 
2.1.4



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

* [PATCH 5/9] toaster: put all test cases into one class
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
                   ` (3 preceding siblings ...)
  2015-08-06 10:15 ` [PATCH 4/9] toaster: get rid of AllProjectsViewTestCase Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 6/9] toaster: get rid of class attribute LAYER_NAME Ed Bartosh
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

Moved all functionality (one setup method and one test case) from
ProvisionedLayersProjectTestCase and XHRDataTypeAheadTestCase to
AllProjectsViewTestCase.

Renamed AllProjectsViewTestCase -> ViewTests.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 40 +++++++++++++--------------------
 1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index bba6f37..0a51c01 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -6,8 +6,8 @@ from orm.models import  Layer, Layer_Version
 
 PROJECT_NAME = "test project"
 
-class AllProjectsViewTestCase(TestCase):
-
+class ViewTests(TestCase):
+    LAYER_NAME = "base-layer"
     def setUp(self):
         self.bbv = BitbakeVersion.objects.create(\
                        name="test bbv", giturl="/tmp/",
@@ -16,6 +16,19 @@ class AllProjectsViewTestCase(TestCase):
                            name="test release", bitbake_version=self.bbv)
         self.project = Project.objects.create_project(name=PROJECT_NAME,
                                                       release=self.release)
+        self.layersrc = LayerSource.objects.create(\
+                               sourcetype=LayerSource.TYPE_IMPORTED)
+        self.priority = ReleaseLayerSourcePriority.objects.create(\
+                               release=self.release,
+                               layer_source=self.layersrc)
+        self.layer = Layer.objects.create(\
+                         name=self.LAYER_NAME,
+                         layer_source=self.layersrc, vcs_url="/tmp/")
+        self.lver = Layer_Version.objects.create(\
+                        layer=self.layer, project=self.project,
+                        layer_source=self.layersrc, commit="master")
+
+        self.assertTrue(self.lver in self.project.compatible_layerversions())
 
     def test_get_base_call_returns_html(self):
         response = self.client.get(reverse('all-projects'), follow=True)
@@ -46,29 +59,6 @@ class AllProjectsViewTestCase(TestCase):
         self.assertTrue("projectPageUrl" in data["rows"][0])
         self.assertTrue("projectBuildsUrl" in data["rows"][0])
 
-class ProvisionedLayersProjectTestCase(ProvisionedProjectTestCase):
-    LAYER_NAME = "base-layer"
-    def setUp(self):
-        super(ProvisionedLayersProjectTestCase, self).setUp()
-        self.layersrc = LayerSource.objects.create(\
-                               sourcetype=LayerSource.TYPE_IMPORTED)
-        self.priority = ReleaseLayerSourcePriority.objects.create(\
-                               release=self.release,
-                               layer_source=self.layersrc)
-        self.layer = Layer.objects.create(\
-                         name=XHRDataTypeAheadTestCase.LAYER_NAME,
-                         layer_source=self.layersrc, vcs_url="/tmp/")
-        self.lver = Layer_Version.objects.create(\
-                        layer=self.layer, project=self.project,
-                        layer_source=self.layersrc, commit="master")
-
-
-class XHRDataTypeAheadTestCase(ProvisionedLayersProjectTestCase):
-
-    def setUp(self):
-        super(XHRDataTypeAheadTestCase, self).setUp()
-        self.assertTrue(self.lver in self.project.compatible_layerversions())
-
     def test_xhr_datatypeahead_layer(self):
         url = reverse('xhr_datatypeahead', args=(self.project.id,))
         response = self.client.get(url, {"type": "versionlayers"})
-- 
2.1.4



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

* [PATCH 6/9] toaster: get rid of class attribute LAYER_NAME
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
                   ` (4 preceding siblings ...)
  2015-08-06 10:15 ` [PATCH 5/9] toaster: put all test cases into one class Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 7/9] toaster: remove unused import Ed Bartosh
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

The attribute doesn't make sense as it's used only once.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 0a51c01..14a847d 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -7,7 +7,6 @@ from orm.models import  Layer, Layer_Version
 PROJECT_NAME = "test project"
 
 class ViewTests(TestCase):
-    LAYER_NAME = "base-layer"
     def setUp(self):
         self.bbv = BitbakeVersion.objects.create(\
                        name="test bbv", giturl="/tmp/",
@@ -22,7 +21,7 @@ class ViewTests(TestCase):
                                release=self.release,
                                layer_source=self.layersrc)
         self.layer = Layer.objects.create(\
-                         name=self.LAYER_NAME,
+                         name="base-layer",
                          layer_source=self.layersrc, vcs_url="/tmp/")
         self.lver = Layer_Version.objects.create(\
                         layer=self.layer, project=self.project,
-- 
2.1.4



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

* [PATCH 7/9] toaster: remove unused import
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
                   ` (5 preceding siblings ...)
  2015-08-06 10:15 ` [PATCH 6/9] toaster: get rid of class attribute LAYER_NAME Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 8/9] toaster: add header and docsting Ed Bartosh
  2015-08-06 10:15 ` [PATCH 9/9] toaster: don't catch json.load exceptions Ed Bartosh
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

Fixed pylint warning:
    Unused Build imported from orm.models (unused-import)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 14a847d..a6b5c9b 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -1,6 +1,6 @@
 from django.test import TestCase
 from django.core.urlresolvers import reverse
-from orm.models import Project, Release, BitbakeVersion, Build
+from orm.models import Project, Release, BitbakeVersion
 from orm.models import ReleaseLayerSourcePriority, LayerSource
 from orm.models import  Layer, Layer_Version
 
-- 
2.1.4



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

* [PATCH 8/9] toaster: add header and docsting
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
                   ` (6 preceding siblings ...)
  2015-08-06 10:15 ` [PATCH 7/9] toaster: remove unused import Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-06 10:15 ` [PATCH 9/9] toaster: don't catch json.load exceptions Ed Bartosh
  8 siblings, 0 replies; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

Added header and docstrings to toastergui tests module.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index a6b5c9b..a549a02 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -1,3 +1,26 @@
+#! /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-2015 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.
+
+"""Test cases for Toaster GUI and ReST."""
+
 from django.test import TestCase
 from django.core.urlresolvers import reverse
 from orm.models import Project, Release, BitbakeVersion
@@ -7,6 +30,8 @@ from orm.models import  Layer, Layer_Version
 PROJECT_NAME = "test project"
 
 class ViewTests(TestCase):
+    """Tests to verify view APIs."""
+
     def setUp(self):
         self.bbv = BitbakeVersion.objects.create(\
                        name="test bbv", giturl="/tmp/",
@@ -30,6 +55,7 @@ class ViewTests(TestCase):
         self.assertTrue(self.lver in self.project.compatible_layerversions())
 
     def test_get_base_call_returns_html(self):
+        """Basic test for all-projects view."""
         response = self.client.get(reverse('all-projects'), follow=True)
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('text/html'))
@@ -37,6 +63,7 @@ class ViewTests(TestCase):
         self.assertTrue(PROJECT_NAME in response.content)
 
     def test_get_json_call_returns_json(self):
+        """Test for all projects output in json format."""
         url = reverse('all-projects')
         response = self.client.get(url, {"format": "json"}, follow=True)
         self.assertEqual(response.status_code, 200)
@@ -59,6 +86,7 @@ class ViewTests(TestCase):
         self.assertTrue("projectBuildsUrl" in data["rows"][0])
 
     def test_xhr_datatypeahead_layer(self):
+        """Test ReST API xhr_datatypeahead."""
         url = reverse('xhr_datatypeahead', args=(self.project.id,))
         response = self.client.get(url, {"type": "versionlayers"})
         self.assertEqual(response.status_code, 200)
-- 
2.1.4



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

* [PATCH 9/9] toaster: don't catch json.load exceptions
  2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
                   ` (7 preceding siblings ...)
  2015-08-06 10:15 ` [PATCH 8/9] toaster: add header and docsting Ed Bartosh
@ 2015-08-06 10:15 ` Ed Bartosh
  2015-08-11 13:07   ` Michael Wood
  8 siblings, 1 reply; 11+ messages in thread
From: Ed Bartosh @ 2015-08-06 10:15 UTC (permalink / raw)
  To: toaster

It doesn't make sense to catch json.load exceptions in the
testing code. It's not a production code and if it fails
because some API doesn't return json code it's better to
see full traceback.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index a549a02..a38cdab 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -21,6 +21,8 @@
 
 """Test cases for Toaster GUI and ReST."""
 
+import json
+
 from django.test import TestCase
 from django.core.urlresolvers import reverse
 from orm.models import Project, Release, BitbakeVersion
@@ -69,11 +71,7 @@ class ViewTests(TestCase):
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('application/json'))
 
-        try:
-            import json
-            data = json.loads(response.content)
-        except:
-            self.fail("Response %s is not json-loadable" % response.content)
+        data = json.loads(response.content)
 
         self.assertTrue("error" in data)
         self.assertEqual(data["error"], "ok")
@@ -92,11 +90,7 @@ class ViewTests(TestCase):
         self.assertEqual(response.status_code, 200)
         self.assertTrue(response['Content-Type'].startswith('application/json'))
 
-        try:
-            import json
-            data = json.loads(response.content)
-        except:
-            self.fail("Response %s is not json-loadable" % response.content)
+        data = json.loads(response.content)
 
         self.assertTrue("error" in data)
         self.assertEqual(data["error"], "ok")
-- 
2.1.4



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

* Re: [PATCH 9/9] toaster: don't catch json.load exceptions
  2015-08-06 10:15 ` [PATCH 9/9] toaster: don't catch json.load exceptions Ed Bartosh
@ 2015-08-11 13:07   ` Michael Wood
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Wood @ 2015-08-11 13:07 UTC (permalink / raw)
  To: toaster

Thanks - Submitted upstream (with the additional patches post-rebase)

On 06/08/15 11:15, Ed Bartosh wrote:
> It doesn't make sense to catch json.load exceptions in the
> testing code. It's not a production code and if it fails
> because some API doesn't return json code it's better to
> see full traceback.
>
> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
> ---
>   bitbake/lib/toaster/toastergui/tests.py | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
> index a549a02..a38cdab 100644
> --- a/bitbake/lib/toaster/toastergui/tests.py
> +++ b/bitbake/lib/toaster/toastergui/tests.py
> @@ -21,6 +21,8 @@
>   
>   """Test cases for Toaster GUI and ReST."""
>   
> +import json
> +
>   from django.test import TestCase
>   from django.core.urlresolvers import reverse
>   from orm.models import Project, Release, BitbakeVersion
> @@ -69,11 +71,7 @@ class ViewTests(TestCase):
>           self.assertEqual(response.status_code, 200)
>           self.assertTrue(response['Content-Type'].startswith('application/json'))
>   
> -        try:
> -            import json
> -            data = json.loads(response.content)
> -        except:
> -            self.fail("Response %s is not json-loadable" % response.content)
> +        data = json.loads(response.content)
>   
>           self.assertTrue("error" in data)
>           self.assertEqual(data["error"], "ok")
> @@ -92,11 +90,7 @@ class ViewTests(TestCase):
>           self.assertEqual(response.status_code, 200)
>           self.assertTrue(response['Content-Type'].startswith('application/json'))
>   
> -        try:
> -            import json
> -            data = json.loads(response.content)
> -        except:
> -            self.fail("Response %s is not json-loadable" % response.content)
> +        data = json.loads(response.content)
>   
>           self.assertTrue("error" in data)
>           self.assertEqual(data["error"], "ok")



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

end of thread, other threads:[~2015-08-11 13:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 10:15 [review request] [PATCH 0/9] ed/toaster/fix-toastergui/tests Ed Bartosh
2015-08-06 10:15 ` [PATCH 1/9] toaster: fix test_get_json_call_returns_json test Ed Bartosh
2015-08-06 10:15 ` [PATCH 2/9] toaster: fix test_xhr_datatypeahead_layer test Ed Bartosh
2015-08-06 10:15 ` [PATCH 3/9] toaster: wrap long lines Ed Bartosh
2015-08-06 10:15 ` [PATCH 4/9] toaster: get rid of AllProjectsViewTestCase Ed Bartosh
2015-08-06 10:15 ` [PATCH 5/9] toaster: put all test cases into one class Ed Bartosh
2015-08-06 10:15 ` [PATCH 6/9] toaster: get rid of class attribute LAYER_NAME Ed Bartosh
2015-08-06 10:15 ` [PATCH 7/9] toaster: remove unused import Ed Bartosh
2015-08-06 10:15 ` [PATCH 8/9] toaster: add header and docsting Ed Bartosh
2015-08-06 10:15 ` [PATCH 9/9] toaster: don't catch json.load exceptions Ed Bartosh
2015-08-11 13:07   ` Michael Wood

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.