diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-08-10 12:21:28 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-17 14:41:42 +0100 |
commit | 958696f5603d5987cd3998371356825a06231e5f (patch) | |
tree | ca46d5e4ce5d523d25ae483c2a249f136e058c70 /bitbake | |
parent | d637b91639fcae376b88319b0f38b3f92cd4c723 (diff) | |
download | poky-958696f5603d5987cd3998371356825a06231e5f.tar.gz |
bitbake: toaster: reformat LayerVersionEquivalenceTestCase
Reformatted to increase readability and satisfy pylint.
Added docstings.
Shortened variable names.
(Bitbake rev: 01e6fb74b60b1a66873f33866a35bdf6b2f807bd)
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')
-rw-r--r-- | bitbake/lib/toaster/orm/tests.py | 124 |
1 files changed, 74 insertions, 50 deletions
diff --git a/bitbake/lib/toaster/orm/tests.py b/bitbake/lib/toaster/orm/tests.py index 3384f01c39..75783ceb82 100644 --- a/bitbake/lib/toaster/orm/tests.py +++ b/bitbake/lib/toaster/orm/tests.py | |||
@@ -59,75 +59,99 @@ class LILSUpdateTestCase(TransactionTestCase): | |||
59 | "no branches fetched") | 59 | "no branches fetched") |
60 | 60 | ||
61 | 61 | ||
62 | # tests to verify layer_version priority selection | ||
63 | class LayerVersionEquivalenceTestCase(TestCase): | 62 | class LayerVersionEquivalenceTestCase(TestCase): |
64 | def setUp(self): | 63 | """Verify Layer_Version priority selection.""" |
65 | # create layer sources | ||
66 | ls = LayerSource.objects.create(name = "dummy-layersource", sourcetype = LayerSource.TYPE_LOCAL) | ||
67 | 64 | ||
68 | # create bitbake version | 65 | def setUp(self): |
69 | bbv = BitbakeVersion.objects.create(name="master", giturl="git://git.openembedded.org/bitbake") | 66 | """Create required objects.""" |
67 | # create layer source | ||
68 | lsrc = LayerSource.objects.create(name="dummy-layersource", | ||
69 | sourcetype=LayerSource.TYPE_LOCAL) | ||
70 | # create release | 70 | # create release |
71 | release = Release.objects.create(name="default-release", bitbake_version = bbv, branch_name = "master") | 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") | ||
72 | # attach layer source to release | 76 | # attach layer source to release |
73 | ReleaseLayerSourcePriority.objects.create(release = release, layer_source = ls, priority = 1) | 77 | ReleaseLayerSourcePriority.objects.create(\ |
78 | release=self.release, layer_source=lsrc, priority=1) | ||
74 | 79 | ||
75 | 80 | # create a layer version for the layer on the specified branch | |
76 | # create layer attach | 81 | self.layer = Layer.objects.create(name="meta-testlayer", |
77 | self.layer = Layer.objects.create(name="meta-testlayer", layer_source = ls) | 82 | layer_source=lsrc) |
78 | # create branch | 83 | self.branch = Branch.objects.create(name="master", layer_source=lsrc) |
79 | self.branch = Branch.objects.create(name="master", layer_source = ls) | 84 | self.lver = Layer_Version.objects.create(\ |
80 | 85 | layer=self.layer, layer_source=lsrc, up_branch=self.branch) | |
81 | # set a layer version for the layer on the specified branch | ||
82 | self.layerversion = Layer_Version.objects.create(layer = self.layer, layer_source = ls, up_branch = self.branch) | ||
83 | 86 | ||
84 | # create spoof layer that should not appear in the search results | 87 | # create spoof layer that should not appear in the search results |
85 | Layer_Version.objects.create(layer = Layer.objects.create(name="meta-notvalid", layer_source = ls), layer_source = ls, up_branch = self.branch) | 88 | layer = Layer.objects.create(name="meta-notvalid", layer_source=lsrc) |
89 | Layer_Version.objects.create(layer=layer, layer_source=lsrc, | ||
90 | up_branch=self.branch) | ||
86 | 91 | ||
87 | 92 | # create project and project layer | |
88 | # create a project ... | 93 | self.project = Project.objects.create_project(name="test-project", |
89 | self.project = Project.objects.create_project(name="test-project", release = release) | 94 | release=self.release) |
90 | # ... and set it up with a single layer version | 95 | ProjectLayer.objects.create(project=self.project, |
91 | ProjectLayer.objects.create(project= self.project, layercommit = self.layerversion) | 96 | layercommit=self.lver) |
92 | 97 | ||
93 | def test_single_layersource(self): | 98 | def test_single_layersource(self): |
94 | # when we have a single layer version, get_equivalents_wpriority() should return a list with just this layer_version | 99 | """ |
95 | equivalent_list = self.layerversion.get_equivalents_wpriority(self.project) | 100 | When we have a single layer version, |
96 | self.assertTrue(len(equivalent_list) == 1) | 101 | get_equivalents_wpriority() should return a list with |
97 | self.assertTrue(equivalent_list[0] == self.layerversion) | 102 | just this layer_version. |
103 | """ | ||
104 | equivqs = self.lver.get_equivalents_wpriority(self.project) | ||
105 | self.assertEqual(list(equivqs), [self.lver]) | ||
98 | 106 | ||
99 | def test_dual_layersource(self): | 107 | def test_dual_layersource(self): |
100 | # 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 | 108 | """ |
101 | ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL, apiurl="test") | 109 | If we have two layers with the same name, from different layer sources, |
110 | we expect both layers in, in increasing priority of the layer source. | ||
111 | """ | ||
112 | lsrc2 = LayerSource.objects.create(\ | ||
113 | name="dummy-layersource2", | ||
114 | sourcetype=LayerSource.TYPE_LOCAL, | ||
115 | apiurl="test") | ||
102 | 116 | ||
103 | # assign a lower priority for the second layer source | 117 | # assign a lower priority for the second layer source |
104 | Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2) | 118 | self.release.releaselayersourcepriority_set.create(layer_source=lsrc2, |
119 | priority=2) | ||
105 | 120 | ||
106 | # create a new layer_version for a layer with the same name coming from the second layer source | 121 | # create a new layer_version for a layer with the same name |
107 | self.layer2 = Layer.objects.create(name="meta-testlayer", layer_source = ls2) | 122 | # coming from the second layer source |
108 | self.layerversion2 = Layer_Version.objects.create(layer = self.layer2, layer_source = ls2, up_branch = self.branch) | 123 | layer2 = Layer.objects.create(name="meta-testlayer", |
124 | layer_source=lsrc2) | ||
125 | lver2 = Layer_Version.objects.create(layer=layer2, layer_source=lsrc2, | ||
126 | up_branch=self.branch) | ||
109 | 127 | ||
110 | # expect two layer versions, in the priority order | 128 | # expect two layer versions, in the priority order |
111 | equivalent_list = self.layerversion.get_equivalents_wpriority(self.project) | 129 | equivqs = self.lver.get_equivalents_wpriority(self.project) |
112 | self.assertTrue(len(equivalent_list) == 2) | 130 | self.assertEqual(list(equivqs), [lver2, self.lver]) |
113 | self.assertTrue(equivalent_list[0] == self.layerversion2) | ||
114 | self.assertTrue(equivalent_list[1] == self.layerversion) | ||
115 | 131 | ||
116 | def test_build_layerversion(self): | 132 | def test_build_layerversion(self): |
117 | # any layer version coming from the build should show up before any layer version coming from upstream | 133 | """ |
118 | build = Build.objects.create(project = self.project, started_on = timezone.now(), completed_on = timezone.now()) | 134 | Any layer version coming from the build should show up |
119 | self.layerversion_build = Layer_Version.objects.create(layer = self.layer, build = build, commit = "deadbeef") | 135 | before any layer version coming from upstream |
120 | 136 | """ | |
121 | # a build layerversion must be in the equivalence list for the original layerversion | 137 | build = Build.objects.create(project=self.project, |
122 | equivalent_list = self.layerversion.get_equivalents_wpriority(self.project) | 138 | started_on=timezone.now(), |
123 | self.assertTrue(len(equivalent_list) == 2) | 139 | completed_on=timezone.now()) |
124 | self.assertTrue(equivalent_list[0] == self.layerversion) | 140 | lvb = Layer_Version.objects.create(layer=self.layer, build=build, |
125 | self.assertTrue(equivalent_list[1] == self.layerversion_build) | 141 | commit="deadbeef") |
126 | 142 | ||
127 | # getting the build layerversion equivalent list must return the same list as the original layer | 143 | # a build layerversion must be in the equivalence |
128 | build_equivalent_list = self.layerversion_build.get_equivalents_wpriority(self.project) | 144 | # list for the original layerversion |
129 | 145 | equivqs = self.lver.get_equivalents_wpriority(self.project) | |
130 | self.assertEqual(list(equivalent_list), list(build_equivalent_list)) | 146 | self.assertTrue(len(equivqs) == 2) |
147 | self.assertTrue(equivqs[0] == self.lver) | ||
148 | self.assertTrue(equivqs[1] == lvb) | ||
149 | |||
150 | # getting the build layerversion equivalent list must | ||
151 | # return the same list as the original layer | ||
152 | bequivqs = lvb.get_equivalents_wpriority(self.project) | ||
153 | |||
154 | self.assertEqual(list(equivqs), list(bequivqs)) | ||
131 | 155 | ||
132 | class ProjectLVSelectionTestCase(TestCase): | 156 | class ProjectLVSelectionTestCase(TestCase): |
133 | def setUp(self): | 157 | def setUp(self): |