bitbake: toaster: toastergui tests Update package test to use CustomImagePackage

Update test for adding and removing a package from a CustomImageRecipe
so that it uses the CustomImagePackage and correct fields for the packages
included. Change the test for error condition to use an invalid package
id as ManyToMany remove() on package that isn't in the relationship does
not throw an error.

(Bitbake rev: daccb2978f833a9e7af270160331da3e9a158219)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood 2015-12-08 16:07:02 +00:00 committed by Richard Purdie
parent 4b3c9d61dc
commit 7e4c231ca2
1 changed files with 16 additions and 9 deletions

View File

@ -30,7 +30,7 @@ from orm.models import Project, Release, BitbakeVersion, Package, LogMessage
from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build
from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target
from orm.models import CustomImageRecipe, ProjectVariable
from orm.models import Branch
from orm.models import Branch, CustomImagePackage
import toastermain
import inspect
@ -176,6 +176,10 @@ class ViewTests(TestCase):
Package.objects.create(name='zpkg1', recipe=self.recipe1, build=build)
self.cust_package = CustomImagePackage.objects.create(
name="ppkg1",
recipe=self.recipe1)
# recipe with project for testing AvailableRecipe table
self.recipe2 = Recipe.objects.create(layer_source=layersrc,
name="fancy-recipe",
@ -404,24 +408,27 @@ class ViewTests(TestCase):
# add self.package to recipe
response = self.client.put(reverse('xhr_customrecipe_packages',
args=(self.customr.id,
self.package.id)))
self.cust_package.id)))
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content),
{"error": "ok",
"dependencies_needed": []})
self.assertEqual(self.customr.package_set.first().name,
self.package.name)
{"error": "ok"})
self.assertEqual(self.customr.appends_set.first().name,
self.cust_package.name)
# delete it
del_url = reverse('xhr_customrecipe_packages',
args=(self.customr.id,
self.customr.package_set.first().id))
self.customr.appends_set.first().id))
response = self.client.delete(del_url)
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content), {"error": "ok"})
self.assertFalse(self.customr.package_set.all())
# delete it again to test error condition
self.assertFalse(self.customr.includes_set.all())
# delete invalid package to test error condition
del_url = reverse('xhr_customrecipe_packages',
args=(self.customr.id,
99999))
response = self.client.delete(del_url)
self.assertEqual(response.status_code, 200)
self.assertNotEqual(json.loads(response.content)["error"], "ok")