Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | # Copyright (C) 2017-2018 Wind River Systems, Inc. |
| 2 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 4 | # |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 6 | from layerindexlib.tests.common import LayersTest |
| 7 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 8 | |
| 9 | class LayerIndexObjectsTest(LayersTest): |
| 10 | def setUp(self): |
| 11 | from layerindexlib import LayerIndexObj, Branch, LayerItem, LayerBranch, LayerDependency, Recipe, Machine, Distro |
| 12 | |
| 13 | LayersTest.setUp(self) |
| 14 | |
| 15 | self.index = LayerIndexObj() |
| 16 | |
| 17 | branchId = 0 |
| 18 | layerItemId = 0 |
| 19 | layerBranchId = 0 |
| 20 | layerDependencyId = 0 |
| 21 | recipeId = 0 |
| 22 | machineId = 0 |
| 23 | distroId = 0 |
| 24 | |
| 25 | self.index.branches = {} |
| 26 | self.index.layerItems = {} |
| 27 | self.index.layerBranches = {} |
| 28 | self.index.layerDependencies = {} |
| 29 | self.index.recipes = {} |
| 30 | self.index.machines = {} |
| 31 | self.index.distros = {} |
| 32 | |
| 33 | branchId += 1 |
| 34 | self.index.branches[branchId] = Branch(self.index) |
| 35 | self.index.branches[branchId].define_data(branchId, |
| 36 | 'test_branch', 'bb_test_branch') |
| 37 | self.index.branches[branchId].lockData() |
| 38 | |
| 39 | layerItemId +=1 |
| 40 | self.index.layerItems[layerItemId] = LayerItem(self.index) |
| 41 | self.index.layerItems[layerItemId].define_data(layerItemId, |
| 42 | 'test_layerItem', vcs_url='git://git_test_url/test_layerItem') |
| 43 | self.index.layerItems[layerItemId].lockData() |
| 44 | |
| 45 | layerBranchId +=1 |
| 46 | self.index.layerBranches[layerBranchId] = LayerBranch(self.index) |
| 47 | self.index.layerBranches[layerBranchId].define_data(layerBranchId, |
| 48 | 'test_collection', '99', layerItemId, |
| 49 | branchId) |
| 50 | |
| 51 | recipeId += 1 |
| 52 | self.index.recipes[recipeId] = Recipe(self.index) |
| 53 | self.index.recipes[recipeId].define_data(recipeId, 'test_git.bb', |
| 54 | 'recipes-test', 'test', 'git', |
| 55 | layerBranchId) |
| 56 | |
| 57 | machineId += 1 |
| 58 | self.index.machines[machineId] = Machine(self.index) |
| 59 | self.index.machines[machineId].define_data(machineId, |
| 60 | 'test_machine', 'test_machine', |
| 61 | layerBranchId) |
| 62 | |
| 63 | distroId += 1 |
| 64 | self.index.distros[distroId] = Distro(self.index) |
| 65 | self.index.distros[distroId].define_data(distroId, |
| 66 | 'test_distro', 'test_distro', |
| 67 | layerBranchId) |
| 68 | |
| 69 | layerItemId +=1 |
| 70 | self.index.layerItems[layerItemId] = LayerItem(self.index) |
| 71 | self.index.layerItems[layerItemId].define_data(layerItemId, 'test_layerItem 2', |
| 72 | vcs_url='git://git_test_url/test_layerItem') |
| 73 | |
| 74 | layerBranchId +=1 |
| 75 | self.index.layerBranches[layerBranchId] = LayerBranch(self.index) |
| 76 | self.index.layerBranches[layerBranchId].define_data(layerBranchId, |
| 77 | 'test_collection_2', '72', layerItemId, |
| 78 | branchId, actual_branch='some_other_branch') |
| 79 | |
| 80 | layerDependencyId += 1 |
| 81 | self.index.layerDependencies[layerDependencyId] = LayerDependency(self.index) |
| 82 | self.index.layerDependencies[layerDependencyId].define_data(layerDependencyId, |
| 83 | layerBranchId, 1) |
| 84 | |
| 85 | layerDependencyId += 1 |
| 86 | self.index.layerDependencies[layerDependencyId] = LayerDependency(self.index) |
| 87 | self.index.layerDependencies[layerDependencyId].define_data(layerDependencyId, |
| 88 | layerBranchId, 1, required=False) |
| 89 | |
| 90 | def test_branch(self): |
| 91 | branch = self.index.branches[1] |
| 92 | self.assertEqual(branch.id, 1) |
| 93 | self.assertEqual(branch.name, 'test_branch') |
| 94 | self.assertEqual(branch.short_description, 'test_branch') |
| 95 | self.assertEqual(branch.bitbake_branch, 'bb_test_branch') |
| 96 | |
| 97 | def test_layerItem(self): |
| 98 | layerItem = self.index.layerItems[1] |
| 99 | self.assertEqual(layerItem.id, 1) |
| 100 | self.assertEqual(layerItem.name, 'test_layerItem') |
| 101 | self.assertEqual(layerItem.summary, 'test_layerItem') |
| 102 | self.assertEqual(layerItem.description, 'test_layerItem') |
| 103 | self.assertEqual(layerItem.vcs_url, 'git://git_test_url/test_layerItem') |
| 104 | self.assertEqual(layerItem.vcs_web_url, None) |
| 105 | self.assertIsNone(layerItem.vcs_web_tree_base_url) |
| 106 | self.assertIsNone(layerItem.vcs_web_file_base_url) |
| 107 | self.assertIsNotNone(layerItem.updated) |
| 108 | |
| 109 | layerItem = self.index.layerItems[2] |
| 110 | self.assertEqual(layerItem.id, 2) |
| 111 | self.assertEqual(layerItem.name, 'test_layerItem 2') |
| 112 | self.assertEqual(layerItem.summary, 'test_layerItem 2') |
| 113 | self.assertEqual(layerItem.description, 'test_layerItem 2') |
| 114 | self.assertEqual(layerItem.vcs_url, 'git://git_test_url/test_layerItem') |
| 115 | self.assertIsNone(layerItem.vcs_web_url) |
| 116 | self.assertIsNone(layerItem.vcs_web_tree_base_url) |
| 117 | self.assertIsNone(layerItem.vcs_web_file_base_url) |
| 118 | self.assertIsNotNone(layerItem.updated) |
| 119 | |
| 120 | def test_layerBranch(self): |
| 121 | layerBranch = self.index.layerBranches[1] |
| 122 | self.assertEqual(layerBranch.id, 1) |
| 123 | self.assertEqual(layerBranch.collection, 'test_collection') |
| 124 | self.assertEqual(layerBranch.version, '99') |
| 125 | self.assertEqual(layerBranch.vcs_subdir, '') |
| 126 | self.assertEqual(layerBranch.actual_branch, 'test_branch') |
| 127 | self.assertIsNotNone(layerBranch.updated) |
| 128 | self.assertEqual(layerBranch.layer_id, 1) |
| 129 | self.assertEqual(layerBranch.branch_id, 1) |
| 130 | self.assertEqual(layerBranch.layer, self.index.layerItems[1]) |
| 131 | self.assertEqual(layerBranch.branch, self.index.branches[1]) |
| 132 | |
| 133 | layerBranch = self.index.layerBranches[2] |
| 134 | self.assertEqual(layerBranch.id, 2) |
| 135 | self.assertEqual(layerBranch.collection, 'test_collection_2') |
| 136 | self.assertEqual(layerBranch.version, '72') |
| 137 | self.assertEqual(layerBranch.vcs_subdir, '') |
| 138 | self.assertEqual(layerBranch.actual_branch, 'some_other_branch') |
| 139 | self.assertIsNotNone(layerBranch.updated) |
| 140 | self.assertEqual(layerBranch.layer_id, 2) |
| 141 | self.assertEqual(layerBranch.branch_id, 1) |
| 142 | self.assertEqual(layerBranch.layer, self.index.layerItems[2]) |
| 143 | self.assertEqual(layerBranch.branch, self.index.branches[1]) |
| 144 | |
| 145 | def test_layerDependency(self): |
| 146 | layerDependency = self.index.layerDependencies[1] |
| 147 | self.assertEqual(layerDependency.id, 1) |
| 148 | self.assertEqual(layerDependency.layerbranch_id, 2) |
| 149 | self.assertEqual(layerDependency.layerbranch, self.index.layerBranches[2]) |
| 150 | self.assertEqual(layerDependency.layer_id, 2) |
| 151 | self.assertEqual(layerDependency.layer, self.index.layerItems[2]) |
| 152 | self.assertTrue(layerDependency.required) |
| 153 | self.assertEqual(layerDependency.dependency_id, 1) |
| 154 | self.assertEqual(layerDependency.dependency, self.index.layerItems[1]) |
| 155 | self.assertEqual(layerDependency.dependency_layerBranch, self.index.layerBranches[1]) |
| 156 | |
| 157 | layerDependency = self.index.layerDependencies[2] |
| 158 | self.assertEqual(layerDependency.id, 2) |
| 159 | self.assertEqual(layerDependency.layerbranch_id, 2) |
| 160 | self.assertEqual(layerDependency.layerbranch, self.index.layerBranches[2]) |
| 161 | self.assertEqual(layerDependency.layer_id, 2) |
| 162 | self.assertEqual(layerDependency.layer, self.index.layerItems[2]) |
| 163 | self.assertFalse(layerDependency.required) |
| 164 | self.assertEqual(layerDependency.dependency_id, 1) |
| 165 | self.assertEqual(layerDependency.dependency, self.index.layerItems[1]) |
| 166 | self.assertEqual(layerDependency.dependency_layerBranch, self.index.layerBranches[1]) |
| 167 | |
| 168 | def test_recipe(self): |
| 169 | recipe = self.index.recipes[1] |
| 170 | self.assertEqual(recipe.id, 1) |
| 171 | self.assertEqual(recipe.layerbranch_id, 1) |
| 172 | self.assertEqual(recipe.layerbranch, self.index.layerBranches[1]) |
| 173 | self.assertEqual(recipe.layer_id, 1) |
| 174 | self.assertEqual(recipe.layer, self.index.layerItems[1]) |
| 175 | self.assertEqual(recipe.filename, 'test_git.bb') |
| 176 | self.assertEqual(recipe.filepath, 'recipes-test') |
| 177 | self.assertEqual(recipe.fullpath, 'recipes-test/test_git.bb') |
| 178 | self.assertEqual(recipe.summary, "") |
| 179 | self.assertEqual(recipe.description, "") |
| 180 | self.assertEqual(recipe.section, "") |
| 181 | self.assertEqual(recipe.pn, 'test') |
| 182 | self.assertEqual(recipe.pv, 'git') |
| 183 | self.assertEqual(recipe.license, "") |
| 184 | self.assertEqual(recipe.homepage, "") |
| 185 | self.assertEqual(recipe.bugtracker, "") |
| 186 | self.assertEqual(recipe.provides, "") |
| 187 | self.assertIsNotNone(recipe.updated) |
| 188 | self.assertEqual(recipe.inherits, "") |
| 189 | |
| 190 | def test_machine(self): |
| 191 | machine = self.index.machines[1] |
| 192 | self.assertEqual(machine.id, 1) |
| 193 | self.assertEqual(machine.layerbranch_id, 1) |
| 194 | self.assertEqual(machine.layerbranch, self.index.layerBranches[1]) |
| 195 | self.assertEqual(machine.layer_id, 1) |
| 196 | self.assertEqual(machine.layer, self.index.layerItems[1]) |
| 197 | self.assertEqual(machine.name, 'test_machine') |
| 198 | self.assertEqual(machine.description, 'test_machine') |
| 199 | self.assertIsNotNone(machine.updated) |
| 200 | |
| 201 | def test_distro(self): |
| 202 | distro = self.index.distros[1] |
| 203 | self.assertEqual(distro.id, 1) |
| 204 | self.assertEqual(distro.layerbranch_id, 1) |
| 205 | self.assertEqual(distro.layerbranch, self.index.layerBranches[1]) |
| 206 | self.assertEqual(distro.layer_id, 1) |
| 207 | self.assertEqual(distro.layer, self.index.layerItems[1]) |
| 208 | self.assertEqual(distro.name, 'test_distro') |
| 209 | self.assertEqual(distro.description, 'test_distro') |
| 210 | self.assertIsNotNone(distro.updated) |