summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/tests.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-05-20 15:44:16 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-29 11:59:46 +0100
commitb3189f307157d0369c019850ab4bdcbec9320006 (patch)
tree6785ea9e42c2dedf568884c4bf95df583033254e /bitbake/lib/toaster/orm/tests.py
parent3480be741ec7bc8fe5b8684e1926447183c6f2c2 (diff)
downloadpoky-b3189f307157d0369c019850ab4bdcbec9320006.tar.gz
bitbake: orm: Fix all failing unit test
This fixes all the unit tests for the orm. Also added is the ability to set a custom Layer index if you want to avoid using the public one by specifying TTS_LAYER_INDEX (Bitbake rev: dfbcbe116d0b987b850f67056f02f489ac0b8360) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/tests.py')
-rw-r--r--bitbake/lib/toaster/orm/tests.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/bitbake/lib/toaster/orm/tests.py b/bitbake/lib/toaster/orm/tests.py
index 7b1b9633f9..d4d97eea0a 100644
--- a/bitbake/lib/toaster/orm/tests.py
+++ b/bitbake/lib/toaster/orm/tests.py
@@ -1,4 +1,4 @@
1from django.test import TestCase 1from django.test import TestCase, TransactionTestCase
2from orm.models import LocalLayerSource, LayerIndexLayerSource, ImportedLayerSource, LayerSource 2from orm.models import LocalLayerSource, LayerIndexLayerSource, ImportedLayerSource, LayerSource
3from orm.models import Branch 3from orm.models import Branch
4 4
@@ -7,6 +7,10 @@ from orm.models import Release, ReleaseLayerSourcePriority, BitbakeVersion
7 7
8from django.utils import timezone 8from django.utils import timezone
9 9
10import os
11
12# set TTS_LAYER_INDEX to the base url to use a different instance of the layer index
13
10# tests to verify inheritance for the LayerSource proxy-inheritance classes 14# tests to verify inheritance for the LayerSource proxy-inheritance classes
11class LayerSourceVerifyInheritanceSaveLoad(TestCase): 15class LayerSourceVerifyInheritanceSaveLoad(TestCase):
12 def test_object_creation(self): 16 def test_object_creation(self):
@@ -29,17 +33,20 @@ class LayerSourceVerifyInheritanceSaveLoad(TestCase):
29 self.assertRaises(Exception, duplicate) 33 self.assertRaises(Exception, duplicate)
30 34
31 35
32# test to verify the layer source update functionality for layerindex. edit to pass the URL to a layerindex application 36class LILSUpdateTestCase(TransactionTestCase):
33class LILSUpdateTestCase(TestCase): 37 def setUp(self):
34 def test_update(self): 38 # create release
35 lils = LayerSource.objects.create(name = "b1", sourcetype = LayerSource.TYPE_LAYERINDEX, apiurl = "http://adamian-desk.local:8080/layerindex/api/") 39 bbv = BitbakeVersion.objects.create(name="master", giturl="git://git.openembedded.org/bitbake")
36 lils.update() 40 release = Release.objects.create(name="default-release", bitbake_version = bbv, branch_name = "master")
37 41
38 # run second update 42 def test_update(self):
39 # lils.update() 43 layer_index_url = os.getenv("TTS_LAYER_INDEX")
44 if layer_index_url == None:
45 print "Using layers.openembedded.org for layer index. override with TTS_LAYER_INDEX enviroment variable"
46 layer_index_url = "http://layers.openembedded.org/"
40 47
41 # print vars(lils) 48 lils = LayerSource.objects.create(name = "b1", sourcetype = LayerSource.TYPE_LAYERINDEX, apiurl = layer_index_url + "layerindex/api/")
42 #print map(lambda x: vars(x), Branch.objects.all()) 49 lils.update()
43 50
44 # run asserts 51 # run asserts
45 self.assertTrue(lils.branch_set.all().count() > 0, "update() needs to fetch some branches") 52 self.assertTrue(lils.branch_set.all().count() > 0, "update() needs to fetch some branches")
@@ -59,6 +66,7 @@ class LayerVersionEquivalenceTestCase(TestCase):
59 # attach layer source to release 66 # attach layer source to release
60 ReleaseLayerSourcePriority.objects.create(release = release, layer_source = ls, priority = 1) 67 ReleaseLayerSourcePriority.objects.create(release = release, layer_source = ls, priority = 1)
61 68
69
62 # create layer attach 70 # create layer attach
63 self.layer = Layer.objects.create(name="meta-testlayer", layer_source = ls) 71 self.layer = Layer.objects.create(name="meta-testlayer", layer_source = ls)
64 # create branch 72 # create branch
@@ -84,7 +92,7 @@ class LayerVersionEquivalenceTestCase(TestCase):
84 92
85 def test_dual_layersource(self): 93 def test_dual_layersource(self):
86 # if we have two layers with the same name, from different layer sources, we expect both layers in, in increasing priority of the layer source 94 # if we have two layers with the same name, from different layer sources, we expect both layers in, in increasing priority of the layer source
87 ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL) 95 ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL, apiurl="test")
88 96
89 # assign a lower priority for the second layer source 97 # assign a lower priority for the second layer source
90 Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2) 98 Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2)
@@ -149,7 +157,7 @@ class ProjectLVSelectionTestCase(TestCase):
149 157
150 def test_dual_layersource(self): 158 def test_dual_layersource(self):
151 # if we have two layers with the same name, from different layer sources, we expect both layers in, in increasing priority of the layer source 159 # if we have two layers with the same name, from different layer sources, we expect both layers in, in increasing priority of the layer source
152 ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL) 160 ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL, apiurl="testing")
153 161
154 # assign a lower priority for the second layer source 162 # assign a lower priority for the second layer source
155 Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2) 163 Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2)