mirror of
https://git.yoctoproject.org/poky
synced 2026-05-08 17:19:20 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
3480be741e
commit
b3189f3071
@@ -782,8 +782,11 @@ class LayerIndexLayerSource(LayerSource):
|
||||
print "EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e))
|
||||
return
|
||||
|
||||
# update branches; only those that we already have names listed in the Releases table
|
||||
# update branches; only those that we already have names listed in the
|
||||
# Releases table
|
||||
whitelist_branch_names = map(lambda x: x.branch_name, Release.objects.all())
|
||||
if len(whitelist_branch_names) == 0:
|
||||
raise Exception("Failed to make list of branches to fetch")
|
||||
|
||||
print "Fetching branches"
|
||||
branches_info = _get_json_response(apilinks['branches']
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, TransactionTestCase
|
||||
from orm.models import LocalLayerSource, LayerIndexLayerSource, ImportedLayerSource, LayerSource
|
||||
from orm.models import Branch
|
||||
|
||||
@@ -7,6 +7,10 @@ from orm.models import Release, ReleaseLayerSourcePriority, BitbakeVersion
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
import os
|
||||
|
||||
# set TTS_LAYER_INDEX to the base url to use a different instance of the layer index
|
||||
|
||||
# tests to verify inheritance for the LayerSource proxy-inheritance classes
|
||||
class LayerSourceVerifyInheritanceSaveLoad(TestCase):
|
||||
def test_object_creation(self):
|
||||
@@ -29,18 +33,21 @@ class LayerSourceVerifyInheritanceSaveLoad(TestCase):
|
||||
self.assertRaises(Exception, duplicate)
|
||||
|
||||
|
||||
# test to verify the layer source update functionality for layerindex. edit to pass the URL to a layerindex application
|
||||
class LILSUpdateTestCase(TestCase):
|
||||
class LILSUpdateTestCase(TransactionTestCase):
|
||||
def setUp(self):
|
||||
# create release
|
||||
bbv = BitbakeVersion.objects.create(name="master", giturl="git://git.openembedded.org/bitbake")
|
||||
release = Release.objects.create(name="default-release", bitbake_version = bbv, branch_name = "master")
|
||||
|
||||
def test_update(self):
|
||||
lils = LayerSource.objects.create(name = "b1", sourcetype = LayerSource.TYPE_LAYERINDEX, apiurl = "http://adamian-desk.local:8080/layerindex/api/")
|
||||
layer_index_url = os.getenv("TTS_LAYER_INDEX")
|
||||
if layer_index_url == None:
|
||||
print "Using layers.openembedded.org for layer index. override with TTS_LAYER_INDEX enviroment variable"
|
||||
layer_index_url = "http://layers.openembedded.org/"
|
||||
|
||||
lils = LayerSource.objects.create(name = "b1", sourcetype = LayerSource.TYPE_LAYERINDEX, apiurl = layer_index_url + "layerindex/api/")
|
||||
lils.update()
|
||||
|
||||
# run second update
|
||||
# lils.update()
|
||||
|
||||
# print vars(lils)
|
||||
#print map(lambda x: vars(x), Branch.objects.all())
|
||||
|
||||
# run asserts
|
||||
self.assertTrue(lils.branch_set.all().count() > 0, "update() needs to fetch some branches")
|
||||
|
||||
@@ -59,6 +66,7 @@ class LayerVersionEquivalenceTestCase(TestCase):
|
||||
# attach layer source to release
|
||||
ReleaseLayerSourcePriority.objects.create(release = release, layer_source = ls, priority = 1)
|
||||
|
||||
|
||||
# create layer attach
|
||||
self.layer = Layer.objects.create(name="meta-testlayer", layer_source = ls)
|
||||
# create branch
|
||||
@@ -84,7 +92,7 @@ class LayerVersionEquivalenceTestCase(TestCase):
|
||||
|
||||
def test_dual_layersource(self):
|
||||
# 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
|
||||
ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL)
|
||||
ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL, apiurl="test")
|
||||
|
||||
# assign a lower priority for the second layer source
|
||||
Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2)
|
||||
@@ -149,7 +157,7 @@ class ProjectLVSelectionTestCase(TestCase):
|
||||
|
||||
def test_dual_layersource(self):
|
||||
# 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
|
||||
ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL)
|
||||
ls2 = LayerSource.objects.create(name = "dummy-layersource2", sourcetype = LayerSource.TYPE_LOCAL, apiurl="testing")
|
||||
|
||||
# assign a lower priority for the second layer source
|
||||
Release.objects.get(name="default-release").releaselayersourcepriority_set.create(layer_source = ls2, priority = 2)
|
||||
|
||||
Reference in New Issue
Block a user