summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-08-10 12:21:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-17 14:41:43 +0100
commit1f7d7bf2164983f8b254ef873b73e074721821db (patch)
tree2073c86af8d1da96dfdaf072c5c90a0228ab7acf /bitbake/lib/toaster/orm
parent958696f5603d5987cd3998371356825a06231e5f (diff)
downloadpoky-1f7d7bf2164983f8b254ef873b73e074721821db.tar.gz
bitbake: toaster: reuse common code
Moved setup code of LayerVersion tests to a function and call it from setUp methods of 2 classes. (Bitbake rev: 65121e71078499ba585cc6a42018339d7884322e) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> 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')
-rw-r--r--bitbake/lib/toaster/orm/tests.py90
1 files changed, 36 insertions, 54 deletions
diff --git a/bitbake/lib/toaster/orm/tests.py b/bitbake/lib/toaster/orm/tests.py
index 75783ceb82..168bafa1de 100644
--- a/bitbake/lib/toaster/orm/tests.py
+++ b/bitbake/lib/toaster/orm/tests.py
@@ -59,42 +59,45 @@ class LILSUpdateTestCase(TransactionTestCase):
59 "no branches fetched") 59 "no branches fetched")
60 60
61 61
62def setup_lv_tests(self):
63 """Create required objects."""
64 # create layer source
65 self.lsrc = LayerSource.objects.create(name="dummy-layersource",
66 sourcetype=LayerSource.TYPE_LOCAL)
67 # create release
68 bbv = BitbakeVersion.objects.create(\
69 name="master", giturl="git://git.openembedded.org/bitbake")
70 self.release = Release.objects.create(name="default-release",
71 bitbake_version=bbv,
72 branch_name="master")
73 # attach layer source to release
74 ReleaseLayerSourcePriority.objects.create(\
75 release=self.release, layer_source=self.lsrc, priority=1)
76
77 # create a layer version for the layer on the specified branch
78 self.layer = Layer.objects.create(name="meta-testlayer",
79 layer_source=self.lsrc)
80 self.branch = Branch.objects.create(name="master", layer_source=self.lsrc)
81 self.lver = Layer_Version.objects.create(\
82 layer=self.layer, layer_source=self.lsrc, up_branch=self.branch)
83
84 # create project and project layer
85 self.project = Project.objects.create_project(name="test-project",
86 release=self.release)
87 ProjectLayer.objects.create(project=self.project,
88 layercommit=self.lver)
89
62class LayerVersionEquivalenceTestCase(TestCase): 90class LayerVersionEquivalenceTestCase(TestCase):
63 """Verify Layer_Version priority selection.""" 91 """Verify Layer_Version priority selection."""
64 92
65 def setUp(self): 93 def setUp(self):
66 """Create required objects.""" 94 setup_lv_tests(self)
67 # create layer source
68 lsrc = LayerSource.objects.create(name="dummy-layersource",
69 sourcetype=LayerSource.TYPE_LOCAL)
70 # create release
71 bbv = BitbakeVersion.objects.create(\
72 name="master", giturl="git://git.openembedded.org/bitbake")
73 self.release = Release.objects.create(name="default-release",
74 bitbake_version=bbv,
75 branch_name="master")
76 # attach layer source to release
77 ReleaseLayerSourcePriority.objects.create(\
78 release=self.release, layer_source=lsrc, priority=1)
79
80 # create a layer version for the layer on the specified branch
81 self.layer = Layer.objects.create(name="meta-testlayer",
82 layer_source=lsrc)
83 self.branch = Branch.objects.create(name="master", layer_source=lsrc)
84 self.lver = Layer_Version.objects.create(\
85 layer=self.layer, layer_source=lsrc, up_branch=self.branch)
86
87 # create spoof layer that should not appear in the search results 95 # create spoof layer that should not appear in the search results
88 layer = Layer.objects.create(name="meta-notvalid", layer_source=lsrc) 96 layer = Layer.objects.create(name="meta-notvalid",
89 Layer_Version.objects.create(layer=layer, layer_source=lsrc, 97 layer_source=self.lsrc)
98 Layer_Version.objects.create(layer=layer, layer_source=self.lsrc,
90 up_branch=self.branch) 99 up_branch=self.branch)
91 100
92 # create project and project layer
93 self.project = Project.objects.create_project(name="test-project",
94 release=self.release)
95 ProjectLayer.objects.create(project=self.project,
96 layercommit=self.lver)
97
98 def test_single_layersource(self): 101 def test_single_layersource(self):
99 """ 102 """
100 When we have a single layer version, 103 When we have a single layer version,
@@ -154,35 +157,14 @@ class LayerVersionEquivalenceTestCase(TestCase):
154 self.assertEqual(list(equivqs), list(bequivqs)) 157 self.assertEqual(list(equivqs), list(bequivqs))
155 158
156class ProjectLVSelectionTestCase(TestCase): 159class ProjectLVSelectionTestCase(TestCase):
157 def setUp(self):
158 # create layer sources
159 ls = LayerSource.objects.create(name = "dummy-layersource", sourcetype = LayerSource.TYPE_LOCAL)
160 160
161 # create bitbake version 161 def setUp(self):
162 bbv = BitbakeVersion.objects.create(name="master", giturl="git://git.openembedded.org/bitbake") 162 setup_lv_tests(self)
163 # create release
164 release = Release.objects.create(name="default-release", bitbake_version = bbv, branch_name="master")
165 # attach layer source to release
166 ReleaseLayerSourcePriority.objects.create(release = release, layer_source = ls, priority = 1)
167
168 # create layer attach
169 self.layer = Layer.objects.create(name="meta-testlayer", layer_source = ls)
170 # create branch
171 self.branch = Branch.objects.create(name="master", layer_source = ls)
172
173 # set a layer version for the layer on the specified branch
174 self.layerversion = Layer_Version.objects.create(layer = self.layer, layer_source = ls, up_branch = self.branch)
175
176
177 # create a project ...
178 self.project = Project.objects.create_project(name="test-project", release = release)
179 # ... and set it up with a single layer version
180 ProjectLayer.objects.create(project= self.project, layercommit = self.layerversion)
181 163
182 def test_single_layersource(self): 164 def test_single_layersource(self):
183 compatible_layerversions = self.project.compatible_layerversions() 165 compatible_layerversions = self.project.compatible_layerversions()
184 self.assertTrue(len(compatible_layerversions) == 1) 166 self.assertTrue(len(compatible_layerversions) == 1)
185 self.assertTrue(compatible_layerversions[0] == self.layerversion) 167 self.assertTrue(compatible_layerversions[0] == self.lver)
186 168
187 169
188 def test_dual_layersource(self): 170 def test_dual_layersource(self):
@@ -200,4 +182,4 @@ class ProjectLVSelectionTestCase(TestCase):
200 equivalent_list = self.project.compatible_layerversions() 182 equivalent_list = self.project.compatible_layerversions()
201 self.assertTrue(len(equivalent_list) == 2) 183 self.assertTrue(len(equivalent_list) == 2)
202 self.assertTrue(equivalent_list[0] == self.layerversion2) 184 self.assertTrue(equivalent_list[0] == self.layerversion2)
203 self.assertTrue(equivalent_list[1] == self.layerversion) 185 self.assertTrue(equivalent_list[1] == self.lver)