summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 39586e0d24..a9edd546fc 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -1,16 +1,22 @@
1from django.test import TestCase 1from django.test import TestCase
2from django.core.urlresolvers import reverse 2from django.core.urlresolvers import reverse
3from orm.models import Project, Release, BitbakeVersion, Build 3from orm.models import Project, Release, BitbakeVersion, Build
4from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Layer_Version, Recipe, Machine, ProjectLayer 4from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer
5from orm.models import Layer_Version, Recipe, Machine, ProjectLayer
5import json 6import json
6 7
8PROJECT_NAME = "test project"
9
7class ProvisionedProjectTestCase(TestCase): 10class ProvisionedProjectTestCase(TestCase):
8 TEST_PROJECT_NAME = "test project"
9 11
10 def setUp(self): 12 def setUp(self):
11 self.bbv, created = BitbakeVersion.objects.get_or_create(name="test bbv", giturl="/tmp/", branch="master", dirpath="") 13 self.bbv = BitbakeVersion.objects.create(\
12 self.release, created = Release.objects.get_or_create(name="test release", bitbake_version = self.bbv) 14 name="test bbv", giturl="/tmp/",
13 self.project = Project.objects.create_project(name=AllProjectsViewTestCase.TEST_PROJECT_NAME, release=self.release) 15 branch="master", dirpath="")
16 self.release = Release.objects.create(\
17 name="test release", bitbake_version=self.bbv)
18 self.project = Project.objects.create_project(name=PROJECT_NAME,
19 release=self.release)
14 20
15 21
16class AllProjectsViewTestCase(ProvisionedProjectTestCase): 22class AllProjectsViewTestCase(ProvisionedProjectTestCase):
@@ -20,10 +26,11 @@ class AllProjectsViewTestCase(ProvisionedProjectTestCase):
20 self.assertEqual(response.status_code, 200) 26 self.assertEqual(response.status_code, 200)
21 self.assertTrue(response['Content-Type'].startswith('text/html')) 27 self.assertTrue(response['Content-Type'].startswith('text/html'))
22 self.assertTemplateUsed(response, "projects.html") 28 self.assertTemplateUsed(response, "projects.html")
23 self.assertTrue(AllProjectsViewTestCase.TEST_PROJECT_NAME in response.content) 29 self.assertTrue(PROJECT_NAME in response.content)
24 30
25 def test_get_json_call_returns_json(self): 31 def test_get_json_call_returns_json(self):
26 response = self.client.get(reverse('all-projects'), {"format": "json"}, follow=True) 32 url = reverse('all-projects')
33 response = self.client.get(url, {"format": "json"}, follow=True)
27 self.assertEqual(response.status_code, 200) 34 self.assertEqual(response.status_code, 200)
28 self.assertTrue(response['Content-Type'].startswith('application/json')) 35 self.assertTrue(response['Content-Type'].startswith('application/json'))
29 36
@@ -36,7 +43,7 @@ class AllProjectsViewTestCase(ProvisionedProjectTestCase):
36 self.assertEqual(data["error"], "ok") 43 self.assertEqual(data["error"], "ok")
37 self.assertTrue("rows" in data) 44 self.assertTrue("rows" in data)
38 45
39 self.assertTrue(AllProjectsViewTestCase.TEST_PROJECT_NAME in map(lambda x: x["name"], data["rows"])) 46 self.assertTrue(PROJECT_NAME in [x["name"] for x in data["rows"]])
40 self.assertTrue("id" in data["rows"][0]) 47 self.assertTrue("id" in data["rows"][0])
41 self.assertTrue("projectLayersUrl" in data["rows"][0]) 48 self.assertTrue("projectLayersUrl" in data["rows"][0])
42 self.assertTrue("projectPageUrl" in data["rows"][0]) 49 self.assertTrue("projectPageUrl" in data["rows"][0])
@@ -49,10 +56,17 @@ class ProvisionedLayersProjectTestCase(ProvisionedProjectTestCase):
49 56
50 def setUp(self): 57 def setUp(self):
51 super(ProvisionedLayersProjectTestCase, self).setUp() 58 super(ProvisionedLayersProjectTestCase, self).setUp()
52 self.layersource, created = LayerSource.objects.get_or_create(sourcetype = LayerSource.TYPE_IMPORTED) 59 self.layersrc = LayerSource.objects.create(\
53 self.releaselayersourcepriority, created = ReleaseLayerSourcePriority.objects.get_or_create(release = self.release, layer_source = self.layersource) 60 sourcetype=LayerSource.TYPE_IMPORTED)
54 self.layer, created = Layer.objects.get_or_create(name=XHRDataTypeAheadTestCase.LAYER_NAME, layer_source=self.layersource, vcs_url="/tmp/") 61 self.priority = ReleaseLayerSourcePriority.objects.create(\
55 self.lv, created = Layer_Version.objects.get_or_create(layer = self.layer, project = self.project, layer_source=self.layersource, commit="master") 62 release=self.release,
63 layer_source=self.layersrc)
64 self.layer = Layer.objects.create(\
65 name=XHRDataTypeAheadTestCase.LAYER_NAME,
66 layer_source=self.layersrc, vcs_url="/tmp/")
67 self.lver = Layer_Version.objects.create(\
68 layer=self.layer, project=self.project,
69 layer_source=self.layersrc, commit="master")
56 70
57 self.recipe, created = Recipe.objects.get_or_create(layer_source=self.layersource, name=ProvisionedLayersProjectTestCase.RECIPE_NAME, version="1.2", summary="one recipe", description="recipe", layer_version=self.lv) 71 self.recipe, created = Recipe.objects.get_or_create(layer_source=self.layersource, name=ProvisionedLayersProjectTestCase.RECIPE_NAME, version="1.2", summary="one recipe", description="recipe", layer_version=self.lv)
58 72
@@ -66,7 +80,7 @@ class XHRDataTypeAheadTestCase(ProvisionedLayersProjectTestCase):
66 80
67 def setUp(self): 81 def setUp(self):
68 super(XHRDataTypeAheadTestCase, self).setUp() 82 super(XHRDataTypeAheadTestCase, self).setUp()
69 self.assertTrue(self.lv in self.project.compatible_layerversions()) 83 self.assertTrue(self.lver in self.project.compatible_layerversions())
70 84
71 def test_typeaheads(self): 85 def test_typeaheads(self):
72 layers_url = reverse('xhr_layerstypeahead', args=(self.project.id,)) 86 layers_url = reverse('xhr_layerstypeahead', args=(self.project.id,))