All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] mysql migrations and unittests fixes
@ 2016-02-16 19:19 Michael Wood
  2016-02-16 19:19 ` [PATCH 1/5] toaster: orm migrations Sort out migrations mess Michael Wood
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Michael Wood @ 2016-02-16 19:19 UTC (permalink / raw)
  To: toaster

This series contains a clean up of the database migrations to fix the issue that was preventing Toaster from starting up when using mysql backend.
See https://bugzilla.yoctoproject.org/show_bug.cgi?id=9116

After fixing these migrations and getting Toaster to start up properly using mysql backend a number of unittests failed due to differences in testing on sqlite.
To remove these differences I've changed the data that was in the setUp to be more agnostic and added .lower() where needed to make sure the orderby re-ordering in the same way. I also took this opportunitiy to convert the toastergui unit tests to use a django fixture making it easier to load the database state for testing.

Bugs fixed discovered by fixing the unit tests are:
 - toaster: SoftwareRecipesTable apply default order_by
 - toaster: toastergui Fix invalid char test and implementation
and one already reported
 - toaster: PackagesTable show only installed packages

[note files deleted and added in this series]

Michael Wood (5):
  toaster: orm migrations Sort out migrations mess
  toaster: SoftwareRecipesTable apply default order_by
  toaster: toastergui unit tests convert to use fixtures
  toaster: PackagesTable show only installed packages
  toaster: toastergui Fix invalid char test and implementation

 bitbake/lib/toaster/orm/migrations/0001_initial.py |  26 --
 .../orm/migrations/0002_auto_20151210_1209.py      |  41 --
 .../orm/migrations/0002_auto_20151223_1528.py      |  27 --
 .../orm/migrations/0002_customimagerecipe.py       |  24 ++
 .../orm/migrations/0003_customimagepackage.py      |   2 +-
 bitbake/lib/toaster/orm/migrations/0004_merge.py   |  15 -
 .../lib/toaster/orm/migrations/0004_provides.py    |  27 ++
 .../orm/migrations/0005_auto_20160118_1055.py      |  19 -
 .../0006_customimagerecipe_last_updated.py         |  19 -
 .../fixtures/toastergui-unittest-data.xml          | 446 +++++++++++++++++++++
 bitbake/lib/toaster/toastergui/tables.py           |   5 +-
 bitbake/lib/toaster/toastergui/tests.py            | 257 ++----------
 bitbake/lib/toaster/toastergui/views.py            |   7 +-
 13 files changed, 550 insertions(+), 365 deletions(-)
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
 create mode 100644 bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0004_merge.py
 create mode 100644 bitbake/lib/toaster/orm/migrations/0004_provides.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py
 create mode 100644 bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml

-- 
2.5.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] toaster: orm migrations Sort out migrations mess
  2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
@ 2016-02-16 19:19 ` Michael Wood
  2016-02-16 19:19 ` [PATCH 2/5] toaster: SoftwareRecipesTable apply default order_by Michael Wood
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Michael Wood @ 2016-02-16 19:19 UTC (permalink / raw)
  To: toaster

We messed up the migrations by squashing some of the image
customisation model definitions into the initial migration which
has meant some irreversible operations on mysql took place.
This deletes, re-orders and fixes the migrations.

If your schema is up to date you may want to use ./manage migrate
with --fake or --fake-initial to avoid re-applying migrations.

[YOCTO #9116]
---
 bitbake/lib/toaster/orm/migrations/0001_initial.py | 26 --------------
 .../orm/migrations/0002_auto_20151210_1209.py      | 41 ----------------------
 .../orm/migrations/0002_auto_20151223_1528.py      | 27 --------------
 .../orm/migrations/0002_customimagerecipe.py       | 24 +++++++++++++
 .../orm/migrations/0003_customimagepackage.py      |  2 +-
 bitbake/lib/toaster/orm/migrations/0004_merge.py   | 15 --------
 .../lib/toaster/orm/migrations/0004_provides.py    | 27 ++++++++++++++
 .../orm/migrations/0005_auto_20160118_1055.py      | 19 ----------
 .../0006_customimagerecipe_last_updated.py         | 19 ----------
 9 files changed, 52 insertions(+), 148 deletions(-)
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
 create mode 100644 bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0004_merge.py
 create mode 100644 bitbake/lib/toaster/orm/migrations/0004_provides.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
 delete mode 100644 bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py

diff --git a/bitbake/lib/toaster/orm/migrations/0001_initial.py b/bitbake/lib/toaster/orm/migrations/0001_initial.py
index 27fd057..760462f 100644
--- a/bitbake/lib/toaster/orm/migrations/0001_initial.py
+++ b/bitbake/lib/toaster/orm/migrations/0001_initial.py
@@ -58,13 +58,6 @@ class Migration(migrations.Migration):
             ],
         ),
         migrations.CreateModel(
-            name='CustomImageRecipe',
-            fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('name', models.CharField(max_length=100)),
-            ],
-        ),
-        migrations.CreateModel(
             name='HelpText',
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
@@ -436,21 +429,6 @@ class Migration(migrations.Migration):
             field=models.ForeignKey(default=None, to='orm.LayerSource', null=True),
         ),
         migrations.AddField(
-            model_name='customimagerecipe',
-            name='base_recipe',
-            field=models.ForeignKey(to='orm.Recipe'),
-        ),
-        migrations.AddField(
-            model_name='customimagerecipe',
-            name='packages',
-            field=models.ManyToManyField(to='orm.Package'),
-        ),
-        migrations.AddField(
-            model_name='customimagerecipe',
-            name='project',
-            field=models.ForeignKey(to='orm.Project'),
-        ),
-        migrations.AddField(
             model_name='build',
             name='project',
             field=models.ForeignKey(to='orm.Project'),
@@ -520,10 +498,6 @@ class Migration(migrations.Migration):
             unique_together=set([('layer_source', 'up_id'), ('layer_source', 'name')]),
         ),
         migrations.AlterUniqueTogether(
-            name='customimagerecipe',
-            unique_together=set([('name', 'project')]),
-        ),
-        migrations.AlterUniqueTogether(
             name='branch',
             unique_together=set([('layer_source', 'up_id'), ('layer_source', 'name')]),
         ),
diff --git a/bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py b/bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
deleted file mode 100644
index d15ceaa..0000000
--- a/bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('orm', '0001_initial'),
-    ]
-
-    operations = [
-        migrations.AddField(
-            model_name='customimagerecipe',
-            name='recipe_ptr',
-            field=models.OneToOneField(parent_link=True, auto_created=True, default=None, serialize=False, to='orm.Recipe'),
-            preserve_default=False,
-        ),
-        migrations.AlterField(
-            model_name='customimagerecipe',
-            name='base_recipe',
-            field=models.ForeignKey(related_name='based_on_recipe', to='orm.Recipe'),
-        ),
-        migrations.AlterUniqueTogether(
-            name='customimagerecipe',
-            unique_together=set([]),
-        ),
-        migrations.RemoveField(
-            model_name='customimagerecipe',
-            name='id',
-        ),
-        migrations.RemoveField(
-            model_name='customimagerecipe',
-            name='name',
-        ),
-        migrations.RemoveField(
-            model_name='customimagerecipe',
-            name='packages',
-        ),
-    ]
diff --git a/bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py b/bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
deleted file mode 100644
index 194c897..0000000
--- a/bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('orm', '0001_initial'),
-    ]
-
-    operations = [
-        migrations.CreateModel(
-            name='Provides',
-            fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('name', models.CharField(max_length=100)),
-                ('recipe', models.ForeignKey(to='orm.Recipe')),
-            ],
-        ),
-        migrations.AddField(
-            model_name='recipe_dependency',
-            name='via',
-            field=models.ForeignKey(null=True, default=None, to='orm.Provides'),
-        ),
-    ]
diff --git a/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py b/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
new file mode 100644
index 0000000..9cec82e
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('orm', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='CustomImageRecipe',
+            fields=[
+                ('recipe_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='orm.Recipe')),
+                ('last_updated', models.DateTimeField(default=None, null=True)),
+                ('base_recipe', models.ForeignKey(related_name='based_on_recipe', to='orm.Recipe')),
+                ('project', models.ForeignKey(to='orm.Project')),
+            ],
+            bases=('orm.recipe',),
+        ),
+    ]
diff --git a/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py b/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py
index d2ea820..b027f66 100644
--- a/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py
+++ b/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py
@@ -7,7 +7,7 @@ from django.db import migrations, models
 class Migration(migrations.Migration):
 
     dependencies = [
-        ('orm', '0002_auto_20151210_1209'),
+        ('orm', '0002_customimagerecipe'),
     ]
 
     operations = [
diff --git a/bitbake/lib/toaster/orm/migrations/0004_merge.py b/bitbake/lib/toaster/orm/migrations/0004_merge.py
deleted file mode 100644
index 5b9d122..0000000
--- a/bitbake/lib/toaster/orm/migrations/0004_merge.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('orm', '0002_auto_20151223_1528'),
-        ('orm', '0003_customimagepackage'),
-    ]
-
-    operations = [
-    ]
diff --git a/bitbake/lib/toaster/orm/migrations/0004_provides.py b/bitbake/lib/toaster/orm/migrations/0004_provides.py
new file mode 100644
index 0000000..dfde2d1
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0004_provides.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('orm', '0003_customimagepackage'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Provides',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('name', models.CharField(max_length=100)),
+                ('recipe', models.ForeignKey(to='orm.Recipe')),
+            ],
+        ),
+        migrations.AddField(
+            model_name='recipe_dependency',
+            name='via',
+            field=models.ForeignKey(null=True, default=None, to='orm.Provides'),
+        ),
+    ]
diff --git a/bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py b/bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
deleted file mode 100644
index 1120596..0000000
--- a/bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('orm', '0004_merge'),
-    ]
-
-    operations = [
-        migrations.AlterField(
-            model_name='customimagerecipe',
-            name='recipe_ptr',
-            field=models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='orm.Recipe'),
-        ),
-    ]
diff --git a/bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py b/bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py
deleted file mode 100644
index b7a301b..0000000
--- a/bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('orm', '0005_auto_20160118_1055'),
-    ]
-
-    operations = [
-        migrations.AddField(
-            model_name='customimagerecipe',
-            name='last_updated',
-            field=models.DateTimeField(default=None, null=True),
-        ),
-    ]
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] toaster: SoftwareRecipesTable apply default order_by
  2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
  2016-02-16 19:19 ` [PATCH 1/5] toaster: orm migrations Sort out migrations mess Michael Wood
@ 2016-02-16 19:19 ` Michael Wood
  2016-02-16 19:19 ` [PATCH 3/5] toaster: toastergui unit tests convert to use fixtures Michael Wood
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Michael Wood @ 2016-02-16 19:19 UTC (permalink / raw)
  To: toaster

Make sure the default orderby for the SoftwareRecipesTable is applied

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/toastergui/tables.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index 86d111d..5a589d3 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -617,6 +617,7 @@ class SoftwareRecipesTable(RecipesTable):
         super(SoftwareRecipesTable, self).setup_queryset(*args, **kwargs)
 
         self.queryset = self.queryset.filter(is_image=False)
+        self.queryset = self.queryset.order_by(self.default_orderby)
 
 
     def setup_columns(self, *args, **kwargs):
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] toaster: toastergui unit tests convert to use fixtures
  2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
  2016-02-16 19:19 ` [PATCH 1/5] toaster: orm migrations Sort out migrations mess Michael Wood
  2016-02-16 19:19 ` [PATCH 2/5] toaster: SoftwareRecipesTable apply default order_by Michael Wood
@ 2016-02-16 19:19 ` Michael Wood
  2016-02-16 19:19 ` [PATCH 4/5] toaster: PackagesTable show only installed packages Michael Wood
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Michael Wood @ 2016-02-16 19:19 UTC (permalink / raw)
  To: toaster

Instead of having to manually write up in the setUp function all the
different objects to create in the database, just specifiy them in a
fixture and load it. This has the advantage that it can be used on a
live server by using the ./manage.py loaddata command and can then
be inspected.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 .../fixtures/toastergui-unittest-data.xml          | 446 +++++++++++++++++++++
 bitbake/lib/toaster/toastergui/tests.py            | 255 ++----------
 2 files changed, 488 insertions(+), 213 deletions(-)
 create mode 100644 bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml

diff --git a/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
new file mode 100644
index 0000000..2d83ff8
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
@@ -0,0 +1,446 @@
+<?xml version="1.0" encoding="utf-8"?>
+<django-objects version="1.0">
+  <object pk="1" model="orm.project">
+    <field type="CharField" name="name">a test project</field>
+    <field type="CharField" name="short_description"></field>
+    <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
+    <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
+    <field type="DateTimeField" name="created">2016-02-15T18:46:20.098248+00:00</field>
+    <field type="DateTimeField" name="updated">2016-02-15T18:46:20.098392+00:00</field>
+    <field type="IntegerField" name="user_id"><None></None></field>
+    <field type="BooleanField" name="is_default">False</field>
+  </object>
+  <object pk="2" model="orm.project">
+    <field type="CharField" name="name">z test project</field>
+    <field type="CharField" name="short_description"></field>
+    <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
+    <field to="orm.release" name="release" rel="ManyToOneRel">2</field>
+    <field type="DateTimeField" name="created">2016-02-15T18:46:20.107936+00:00</field>
+    <field type="DateTimeField" name="updated">2016-02-15T18:46:20.108066+00:00</field>
+    <field type="IntegerField" name="user_id"><None></None></field>
+    <field type="BooleanField" name="is_default">False</field>
+  </object>
+  <object pk="1" model="orm.ProjectVariable">
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="name">machine</field>
+    <field type="TextField" name="value">qemux86</field>
+  </object>
+  <object pk="2" model="orm.ProjectVariable">
+    <field to="orm.project" name="project" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="name">machine</field>
+    <field type="TextField" name="value">qemux86</field>
+  </object>
+  <object pk="1" model="orm.build">
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="machine">x12</field>
+    <field type="CharField" name="distro"></field>
+    <field type="CharField" name="distro_version"></field>
+    <field type="DateTimeField" name="started_on">2016-02-14T18:46:20.114530+00:00</field>
+    <field type="DateTimeField" name="completed_on">2016-02-14T18:46:20.114530+00:00</field>
+    <field type="IntegerField" name="outcome">0</field>
+    <field type="CharField" name="cooker_log_path"></field>
+    <field type="CharField" name="build_name">a</field>
+    <field type="CharField" name="bitbake_version"></field>
+  </object>
+  <object pk="2" model="orm.build">
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="machine">raspberrypi2</field>
+    <field type="CharField" name="distro"></field>
+    <field type="CharField" name="distro_version"></field>
+    <field type="DateTimeField" name="started_on">2016-02-13T18:46:20.114530+00:00</field>
+    <field type="DateTimeField" name="completed_on">2016-02-13T18:46:20.114530+00:00</field>
+    <field type="IntegerField" name="outcome">0</field>
+    <field type="CharField" name="cooker_log_path"></field>
+    <field type="CharField" name="build_name">b</field>
+    <field type="CharField" name="bitbake_version"></field>
+  </object>
+  <object pk="3" model="orm.build">
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="machine">qemux86</field>
+    <field type="CharField" name="distro"></field>
+    <field type="CharField" name="distro_version"></field>
+    <field type="DateTimeField" name="started_on">2016-02-12T18:46:20.114530+00:00</field>
+    <field type="DateTimeField" name="completed_on">2016-02-12T18:46:20.114530+00:00</field>
+    <field type="IntegerField" name="outcome">1</field>
+    <field type="CharField" name="cooker_log_path"></field>
+    <field type="CharField" name="build_name">c</field>
+    <field type="CharField" name="bitbake_version"></field>
+  </object>
+  <object pk="4" model="orm.build">
+    <field to="orm.project" name="project" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="machine">qemux86</field>
+    <field type="CharField" name="distro"></field>
+    <field type="CharField" name="distro_version"></field>
+    <field type="DateTimeField" name="started_on">2016-02-11T18:46:20.114530+00:00</field>
+    <field type="DateTimeField" name="completed_on">2016-02-11T18:46:20.114530+00:00</field>
+    <field type="IntegerField" name="outcome">0</field>
+    <field type="CharField" name="cooker_log_path"></field>
+    <field type="CharField" name="build_name">d</field>
+    <field type="CharField" name="bitbake_version"></field>
+  </object>
+  <object pk="1" model="orm.target">
+    <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="target">a image recipe</field>
+    <field type="CharField" name="task"><None></None></field>
+    <field type="BooleanField" name="is_image">False</field>
+    <field type="IntegerField" name="image_size">0</field>
+    <field type="CharField" name="license_manifest_path"><None></None></field>
+  </object>
+  <object pk="2" model="orm.target">
+    <field to="orm.build" name="build" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="target">z something</field>
+    <field type="CharField" name="task"><None></None></field>
+    <field type="BooleanField" name="is_image">False</field>
+    <field type="IntegerField" name="image_size">0</field>
+    <field type="CharField" name="license_manifest_path"><None></None></field>
+  </object>
+  <object pk="3" model="orm.target">
+    <field to="orm.build" name="build" rel="ManyToOneRel">3</field>
+    <field type="CharField" name="target">h recipe</field>
+    <field type="CharField" name="task"><None></None></field>
+    <field type="BooleanField" name="is_image">False</field>
+    <field type="IntegerField" name="image_size">0</field>
+    <field type="CharField" name="license_manifest_path"><None></None></field>
+  </object>
+  <object pk="1" model="orm.package">
+    <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
+    <field to="orm.recipe" name="recipe" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="name">b pkg</field>
+    <field type="CharField" name="installed_name"></field>
+    <field type="CharField" name="version"></field>
+    <field type="CharField" name="revision"></field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="IntegerField" name="size">777</field>
+    <field type="IntegerField" name="installed_size">0</field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license">a license</field>
+  </object>
+  <object pk="2" model="orm.package">
+    <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
+    <field to="orm.recipe" name="recipe" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="name">f pkg</field>
+    <field type="CharField" name="installed_name"></field>
+    <field type="CharField" name="version"></field>
+    <field type="CharField" name="revision"></field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="IntegerField" name="size">4</field>
+    <field type="IntegerField" name="installed_size">10</field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license">z license</field>
+  </object>
+  <object pk="3" model="orm.package">
+    <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
+    <field to="orm.recipe" name="recipe" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="name">a custom image pkg</field>
+    <field type="CharField" name="installed_name"></field>
+    <field type="CharField" name="version"></field>
+    <field type="CharField" name="revision"></field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="IntegerField" name="size">10</field>
+    <field type="IntegerField" name="installed_size">0</field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license">h license</field>
+  </object>
+  <object pk="4" model="orm.package">
+    <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
+    <field to="orm.recipe" name="recipe" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="name">z custom image pkg</field>
+    <field type="CharField" name="installed_name"></field>
+    <field type="CharField" name="version"></field>
+    <field type="CharField" name="revision"></field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="IntegerField" name="size">5</field>
+    <field type="IntegerField" name="installed_size">0</field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license">z license</field>
+  </object>
+  <object pk="5" model="orm.package">
+    <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
+    <field to="orm.recipe" name="recipe" rel="ManyToOneRel">4</field>
+    <field type="CharField" name="name">a custom image pkg</field>
+    <field type="CharField" name="installed_name"></field>
+    <field type="CharField" name="version"></field>
+    <field type="CharField" name="revision"></field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="IntegerField" name="size">2</field>
+    <field type="IntegerField" name="installed_size">0</field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license">h licence</field>
+  </object>
+  <object pk="1" model="orm.target_installed_package">
+    <field to="orm.target" name="target" rel="ManyToOneRel">1</field>
+    <field to="orm.package" name="package" rel="ManyToOneRel">1</field>
+  </object>
+  <object pk="2" model="orm.target_installed_package">
+    <field to="orm.target" name="target" rel="ManyToOneRel">1</field>
+    <field to="orm.package" name="package" rel="ManyToOneRel">2</field>
+  </object>
+  <object pk="3" model="orm.target_installed_package">
+    <field to="orm.target" name="target" rel="ManyToOneRel">1</field>
+    <field to="orm.package" name="package" rel="ManyToOneRel">3</field>
+  </object>
+  <!-- Note that these augment the existing orm.package of the same pk -->
+  <object pk="4" model="orm.customimagepackage">
+    <field to="orm.customimagerecipe" name="recipe_includes" rel="ManyToManyRel"></field>
+    <field to="orm.customimagerecipe" name="recipe_excludes" rel="ManyToManyRel"></field>
+    <field to="orm.customimagerecipe" name="recipe_appends" rel="ManyToManyRel"><object pk="3"></object></field>
+  </object>
+  <object pk="5" model="orm.customimagepackage">
+    <field to="orm.customimagerecipe" name="recipe_includes" rel="ManyToManyRel"></field>
+    <field to="orm.customimagerecipe" name="recipe_excludes" rel="ManyToManyRel"></field>
+    <field to="orm.customimagerecipe" name="recipe_appends" rel="ManyToManyRel"><object pk="3"></object></field>
+  </object>
+  <object pk="1" model="orm.recipe">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">z recipe</field>
+    <field type="CharField" name="version">5.2</field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
+    <field type="TextField" name="summary">z recipe</field>
+    <field type="TextField" name="description">z recipe</field>
+    <field type="CharField" name="section">z section</field>
+    <field type="CharField" name="license">z license</field>
+    <field type="CharField" name="homepage"></field>
+    <field type="CharField" name="bugtracker"></field>
+    <field type="FilePathField" name="file_path"></field>
+    <field type="CharField" name="pathflags"></field>
+    <field type="BooleanField" name="is_image">False</field>
+  </object>
+  <object pk="2" model="orm.recipe">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">a recipe</field>
+    <field type="CharField" name="version">1.2</field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
+    <field type="TextField" name="summary">a recipe</field>
+    <field type="TextField" name="description">a recipe</field>
+    <field type="CharField" name="section">a section</field>
+    <field type="CharField" name="license">a license</field>
+    <field type="CharField" name="homepage"></field>
+    <field type="CharField" name="bugtracker"></field>
+    <field type="FilePathField" name="file_path">a_recipe.bb</field>
+    <field type="CharField" name="pathflags"></field>
+    <field type="BooleanField" name="is_image">False</field>
+  </object>
+  <object pk="3" model="orm.recipe">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">a custom recipe</field>
+    <field type="CharField" name="version"></field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license"></field>
+    <field type="CharField" name="homepage"></field>
+    <field type="CharField" name="bugtracker"></field>
+    <field type="FilePathField" name="file_path">custr</field>
+    <field type="CharField" name="pathflags"></field>
+    <field type="BooleanField" name="is_image">False</field>
+  </object>
+  <object pk="4" model="orm.recipe">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">a image recipe</field>
+    <field type="CharField" name="version">1.2</field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
+    <field type="TextField" name="summary">one recipe</field>
+    <field type="TextField" name="description">recipe</field>
+    <field type="CharField" name="section">A</field>
+    <field type="CharField" name="license">A</field>
+    <field type="CharField" name="homepage"></field>
+    <field type="CharField" name="bugtracker"></field>
+    <field type="FilePathField" name="file_path">/one/</field>
+    <field type="CharField" name="pathflags"></field>
+    <field type="BooleanField" name="is_image">True</field>
+  </object>
+  <object pk="5" model="orm.recipe">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">z image recipe</field>
+    <field type="CharField" name="version">1.3</field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
+    <field type="TextField" name="summary">two image recipe</field>
+    <field type="TextField" name="description">recipe two</field>
+    <field type="CharField" name="section">B</field>
+    <field type="CharField" name="license">Z</field>
+    <field type="CharField" name="homepage"></field>
+    <field type="CharField" name="bugtracker"></field>
+    <field type="FilePathField" name="file_path">/two/</field>
+    <field type="CharField" name="pathflags"></field>
+    <field type="BooleanField" name="is_image">True</field>
+  </object>
+  <object pk="6" model="orm.recipe">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">z custom recipe</field>
+    <field type="CharField" name="version"></field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
+    <field type="TextField" name="summary"></field>
+    <field type="TextField" name="description"></field>
+    <field type="CharField" name="section"></field>
+    <field type="CharField" name="license"></field>
+    <field type="CharField" name="homepage"></field>
+    <field type="CharField" name="bugtracker"></field>
+    <field type="FilePathField" name="file_path">zzzz</field>
+    <field type="CharField" name="pathflags"></field>
+    <field type="BooleanField" name="is_image">False</field>
+  </object>
+  <object pk="1" model="orm.machine">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="name">a machine</field>
+    <field type="CharField" name="description">a machine</field>
+  </object>
+  <object pk="2" model="orm.machine">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
+    <field type="CharField" name="name">z machine</field>
+    <field type="CharField" name="description">z machine</field>
+  </object>
+  <object pk="3" model="orm.machine">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="name">g machine</field>
+    <field type="CharField" name="description">g machine</field>
+  </object>
+  <object pk="1" model="orm.layersource">
+    <field type="CharField" name="name">local</field>
+    <field type="IntegerField" name="sourcetype">1</field>
+    <field type="CharField" name="apiurl"></field>
+  </object>
+  <object pk="1" model="orm.bitbakeversion">
+    <field type="CharField" name="name">test bbv</field>
+    <field type="CharField" name="giturl">/tmp/</field>
+    <field type="CharField" name="branch">master</field>
+    <field type="CharField" name="dirpath"></field>
+  </object>
+  <object pk="1" model="orm.release">
+    <field type="CharField" name="name">test release</field>
+    <field type="CharField" name="description"></field>
+    <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="branch_name">master</field>
+    <field type="TextField" name="helptext"><None></None></field>
+  </object>
+  <object pk="2" model="orm.release">
+    <field type="CharField" name="name">test release 2</field>
+    <field type="CharField" name="description"></field>
+    <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="branch_name">master</field>
+    <field type="TextField" name="helptext"><None></None></field>
+  </object>
+  <object pk="1" model="orm.releaselayersourcepriority">
+    <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="priority">0</field>
+  </object>
+  <object pk="1" model="orm.branch">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">master</field>
+    <field type="CharField" name="short_description"></field>
+  </object>
+  <object pk="1" model="orm.layer">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">a layer</field>
+    <field type="CharField" name="layer_index_url"></field>
+    <field type="CharField" name="vcs_url">/tmp/</field>
+    <field type="CharField" name="vcs_web_url"><None></None></field>
+    <field type="CharField" name="vcs_web_tree_base_url"><None></None></field>
+    <field type="CharField" name="vcs_web_file_base_url"><None></None></field>
+    <field type="TextField" name="summary"><None></None></field>
+    <field type="TextField" name="description"><None></None></field>
+  </object>
+  <object pk="2" model="orm.layer">
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field type="CharField" name="name">z layer</field>
+    <field type="CharField" name="layer_index_url"></field>
+    <field type="CharField" name="vcs_url">git://two/</field>
+    <field type="CharField" name="vcs_web_url"><None></None></field>
+    <field type="CharField" name="vcs_web_tree_base_url"><None></None></field>
+    <field type="CharField" name="vcs_web_file_base_url"><None></None></field>
+    <field type="TextField" name="summary"><None></None></field>
+    <field type="TextField" name="description"><None></None></field>
+  </object>
+  <object pk="1" model="orm.layer_version">
+    <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
+    <field to="orm.layer" name="layer" rel="ManyToOneRel">1</field>
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="branch"></field>
+    <field type="CharField" name="commit">master</field>
+    <field type="CharField" name="dirpath">/tmp/</field>
+    <field type="IntegerField" name="priority">0</field>
+    <field type="FilePathField" name="local_path">/</field>
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+  </object>
+  <object pk="2" model="orm.layer_version">
+    <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
+    <field to="orm.layer" name="layer" rel="ManyToOneRel">2</field>
+    <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
+    <field type="IntegerField" name="up_id"><None></None></field>
+    <field type="DateTimeField" name="up_date"><None></None></field>
+    <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field>
+    <field type="CharField" name="branch"></field>
+    <field type="CharField" name="commit">master</field>
+    <field type="CharField" name="dirpath"><None></None></field>
+    <field type="IntegerField" name="priority">0</field>
+    <field type="FilePathField" name="local_path">/</field>
+    <field to="orm.project" name="project" rel="ManyToOneRel"><None></None></field>
+  </object>
+  <object pk="1" model="orm.projectlayer">
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field to="orm.layer_version" name="layercommit" rel="ManyToOneRel">1</field>
+    <field type="BooleanField" name="optional">True</field>
+  </object>
+  <object pk="3" model="orm.customimagerecipe">
+    <field to="orm.recipe" name="base_recipe" rel="ManyToOneRel">2</field>
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field type="DateTimeField" name="last_updated"><None></None></field>
+  </object>
+  <object pk="6" model="orm.customimagerecipe">
+    <field to="orm.recipe" name="base_recipe" rel="ManyToOneRel">4</field>
+    <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
+    <field type="DateTimeField" name="last_updated"><None></None></field>
+  </object>
+  <object pk="1" model="orm.logmessage">
+    <field to="orm.build" name="build" rel="ManyToOneRel">2</field>
+    <field to="orm.task" name="task" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="level">1</field>
+    <field type="TextField" name="message"><None></None></field>
+    <field type="FilePathField" name="pathname"></field>
+    <field type="IntegerField" name="lineno"><None></None></field>
+  </object>
+  <object pk="2" model="orm.logmessage">
+    <field to="orm.build" name="build" rel="ManyToOneRel">2</field>
+    <field to="orm.task" name="task" rel="ManyToOneRel"><None></None></field>
+    <field type="IntegerField" name="level">2</field>
+    <field type="TextField" name="message"><None></None></field>
+    <field type="FilePathField" name="pathname"></field>
+    <field type="IntegerField" name="lineno"><None></None></field>
+  </object>
+</django-objects>
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 56a7d7e..1b6e78d 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -51,205 +51,17 @@ CLI_BUILDS_PROJECT_NAME = 'Command line builds'
 class ViewTests(TestCase):
     """Tests to verify view APIs."""
 
-    def setUp(self):
-        bbv = BitbakeVersion.objects.create(name="test bbv", giturl="/tmp/",
-                                            branch="master", dirpath="")
-        release = Release.objects.create(name="test release",
-                                         branch_name="master",
-                                         bitbake_version=bbv)
-        release2 = Release.objects.create(name="test release 2",
-                                          branch_name="master",
-                                          bitbake_version=bbv)
-
-        self.project = Project.objects.create_project(name=PROJECT_NAME,
-                                                      release=release)
-
-        self.project2 = Project.objects.create_project(name=PROJECT_NAME2,
-                                                       release=release2)
-
-        now = timezone.now()
-        later = now + timedelta(days=1)
-
-        build = Build.objects.create(project=self.project,
-                                     started_on=now,
-                                     completed_on=now,
-                                     outcome=Build.SUCCEEDED)
-
-        # for testing BuildsTable
-        build1 = Build.objects.create(project=self.project,
-                                      started_on=now,
-                                      completed_on=now,
-                                      outcome=Build.SUCCEEDED,
-                                      machine="raspberrypi2")
-
-        Build.objects.create(project=self.project,
-                             started_on=later,
-                             completed_on=later,
-                             outcome=Build.FAILED,
-                             machine="qemux86")
-
-        Build.objects.create(project=self.project2,
-                             started_on=later,
-                             completed_on=later,
-                             outcome=Build.SUCCEEDED,
-                             machine="qemux86")
-
-        # to test sorting by errors and warnings in BuildsTable
-        LogMessage.objects.create(build=build1, level=LogMessage.WARNING)
-        LogMessage.objects.create(build=build1, level=LogMessage.ERROR)
-
-        layersrc = LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED)
-        self.priority = ReleaseLayerSourcePriority.objects.create(release=release,
-                                                                  layer_source=layersrc)
-        layer = Layer.objects.create(name="base-layer", layer_source=layersrc,
-                                     vcs_url="/tmp/")
-
-        layer_two = Layer.objects.create(name="z-layer",
-                                         layer_source=layersrc,
-                                         vcs_url="git://two/")
-
-
-        branch = Branch.objects.create(name="master", layer_source=layersrc)
-
-        self.lver = Layer_Version.objects.create(layer=layer,
-                                                 project=self.project,
-                                                 layer_source=layersrc,
-                                                 commit="master",
-                                                 dirpath="/tmp/",
-                                                 up_branch=branch)
-
-        lver_two = Layer_Version.objects.create(layer=layer_two,
-                                                layer_source=layersrc,
-                                                commit="master",
-                                                up_branch=branch)
-
-        Recipe.objects.create(layer_source=layersrc,
-                              name="z recipe",
-                              version="5.2",
-                              summary="z recipe",
-                              description="G recipe",
-                              license="Z GPL",
-                              section="h section",
-                              layer_version=lver_two)
-
-        # Create a dummy recipe file for the custom image generation to read
-        open("/tmp/my_recipe.bb", 'wa').close()
-        self.recipe1 = Recipe.objects.create(layer_source=layersrc,
-                                             name="base-recipe",
-                                             version="1.2",
-                                             summary="one recipe",
-                                             description="recipe",
-                                             section="A section",
-                                             license="Apache",
-                                             layer_version=self.lver,
-                                             file_path="my_recipe.bb")
-
-        Machine.objects.create(layer_version=self.lver, name="wisk",
-                               description="wisking machine")
-        Machine.objects.create(layer_version=self.lver, name="zap",
-                               description="zap machine")
-        Machine.objects.create(layer_version=lver_two, name="xray",
-                               description="xray machine")
-
-
-
-        ProjectLayer.objects.create(project=self.project, layercommit=self.lver)
-
-        lver_custom = Layer_Version.objects.create(layer=layer,
-                                                   project=self.project,
-                                                   layer_source=layersrc,
-                                                   commit="mymaster",
-                                                   up_branch=branch)
-
-        self.customr = CustomImageRecipe.objects.create(\
-                           name="custom recipe", project=self.project,
-                           base_recipe=self.recipe1,
-                           file_path="custr",
-                           layer_version=lver_custom)
-
-        self.package = Package.objects.create(name='pkg1',
-                                              size=999,
-                                              recipe=self.recipe1,
-                                              license="HHH",
-                                              build=build)
-
-        Package.objects.create(name='A pkg1',
-                               size=777,
-                               recipe=self.recipe1,
-                               build=build)
-
-        Package.objects.create(name='zpkg1',
-                               recipe=self.recipe1,
-                               build=build,
-                               size=4,
-                               license="ZZ")
-
-        self.cust_package = CustomImagePackage.objects.create(
-            name="A pkg",
-            recipe=self.recipe1,
-            size=10,
-            license="AAA")
-
-        self.customr.appends_set.add(self.cust_package)
-
-        # recipe with project for testing AvailableRecipe table
-        self.recipe2 = Recipe.objects.create(layer_source=layersrc,
-                                             name="fancy-recipe",
-                                             version="1.4",
-                                             summary="a fancy recipe",
-                                             description="fancy recipe",
-                                             license="MIT",
-                                             layer_version=self.lver,
-                                             section="Z section",
-                                             file_path='/home/foo')
-
-        # additional package for the sorting for the SelectPackagesTable
-        cust_package_two = CustomImagePackage.objects.create(name="ZZ pkg",
-                                                        size=5,
-                                                        recipe=self.recipe2)
-
-        self.customr.appends_set.add(cust_package_two)
-
-        Package.objects.create(name='one1',
-                               recipe=self.recipe2,
-                               build=build,
-                               size=2,
-                               license="L")
-
-        Recipe.objects.create(layer_source=layersrc,
-                              is_image=True,
-                              name="Test image one",
-                              version="1.2",
-                              summary="one recipe",
-                              description="recipe",
-                              section="A",
-                              license="A",
-                              file_path="/one/",
-                              layer_version=self.lver)
-
-        zrecipe = Recipe.objects.create(layer_source=layersrc,
-                                        is_image=True,
-                                        name="Z Test image two",
-                                        version="1.3",
-                                        summary="two image recipe",
-                                        description="recipe two",
-                                        section="B",
-                                        license="Z",
-                                        file_path="/two/",
-                                        layer_version=lver_two)
-
-        CustomImageRecipe.objects.create(name="z custom recipe",
-                                         project=self.project,
-                                         base_recipe=zrecipe,
-                                         file_path="zzzz",
-                                         layer_version=lver_custom)
-
-        # Packages in PackagesTable requre that the recipe has been built so
-        # we need to create a target and build pair
-        target = Target.objects.create(target=self.recipe1.name,
-                                       build=build)
+    fixtures = ['toastergui-unittest-data']
 
+    def setUp(self):
 
+        self.project = Project.objects.first()
+        self.recipe1 = Recipe.objects.get(pk=2)
+        self.recipe2 = Recipe.objects.last()
+        self.customr = CustomImageRecipe.objects.first()
+        self.cust_package = CustomImagePackage.objects.first()
+        self.package = Package.objects.first()
+        self.lver = Layer_Version.objects.first()
 
     def test_get_base_call_returns_html(self):
         """Basic test for all-projects view"""
@@ -271,7 +83,7 @@ class ViewTests(TestCase):
         self.assertEqual(data["error"], "ok")
         self.assertTrue("rows" in data)
 
-        self.assertTrue(PROJECT_NAME in [x["name"] for x in data["rows"]])
+        self.assertTrue(self.project.name in [x["name"] for x in data["rows"]])
         self.assertTrue("id" in data["rows"][0])
 
     def test_typeaheads(self):
@@ -333,11 +145,13 @@ class ViewTests(TestCase):
 
     def test_xhr_import_layer(self):
         """Test xhr_importlayer API"""
+        LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED)
         #Test for importing an already existing layer
         args = {'vcs_url' : "git://git.example.com/test",
                 'name' : "base-layer",
                 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
-                'project_id': 1, 'dir_path' : "/path/in/repository"}
+                'project_id': self.project.id,
+                'dir_path' : "/path/in/repository"}
         response = self.client.post(reverse('xhr_importlayer'), args)
         data = json.loads(response.content)
         self.assertEqual(response.status_code, 200)
@@ -407,13 +221,12 @@ class ViewTests(TestCase):
 
     def test_xhr_custom_details(self):
         """Test getting custom recipe details"""
-        name = "custom recipe"
         url = reverse('xhr_customrecipe_id', args=(self.customr.id,))
         response = self.client.get(url)
         self.assertEqual(response.status_code, 200)
         expected = {"error": "ok",
                     "info": {'id': self.customr.id,
-                             'name': name,
+                             'name': self.customr.name,
                              'base_recipe_id': self.recipe1.id,
                              'project_id': self.project.id,
                             }
@@ -484,6 +297,10 @@ class ViewTests(TestCase):
                                     {"error": "ok"})
 
     def test_download_custom_recipe(self):
+        """Download the recipe file generated for the custom image"""
+
+        # Create a dummy recipe file for the custom image generation to read
+        open("/tmp/a_recipe.bb", 'wa').close()
         response = self.client.get(reverse('customrecipedownload',
                                            args=(self.project.id,
                                                  self.customr.id)))
@@ -503,8 +320,6 @@ class ViewTests(TestCase):
         row2 = next(x for x in rows if x['name'] == self.recipe2.name)
 
         self.assertEqual(response.status_code, 200, 'should be 200 OK status')
-        # All recipes in the setUp
-        self.assertEqual(len(rows), 5, 'should be 5 recipes')
 
         # check other columns have been populated correctly
         self.assertEqual(row1['name'], self.recipe1.name)
@@ -529,13 +344,20 @@ class ViewTests(TestCase):
             options['format'] = "json"
             options['nocache'] = "true"
             request = RequestFactory().get('/', options)
+
+            # This is the image recipe needed for a package list for
+            # PackagesTable do this here to throw a non exist exception
+            image_recipe = Recipe.objects.get(pk=4)
+
             # Add any kwargs that are needed by any of the possible tables
-            response = table.get(request,
-                                 pid=self.project.id,
-                                 layerid=self.lver.pk,
-                                 recipeid=self.recipe1.pk,
-                                 recipe_id=self.recipe1.pk,
-                                 custrecipeid=self.customr.pk)
+            args = {'pid': self.project.id,
+                    'layerid': self.lver.pk,
+                    'recipeid': self.recipe1.pk,
+                    'recipe_id': image_recipe.pk,
+                    'custrecipeid': self.customr.pk
+                   }
+
+            response = table.get(request, **args)
             return json.loads(response.content)
 
         # Get a list of classes in tables module
@@ -562,10 +384,14 @@ class ViewTests(TestCase):
 
                 if '-' in table.default_orderby:
                     self.assertTrue(row_one >= row_two,
-                                    "Default ordering not working on %s" % name)
+                                    "Default ordering not working on %s"
+                                    " '%s' should be >= '%s'" %
+                                    (name, row_one, row_two))
                 else:
                     self.assertTrue(row_one <= row_two,
-                                    "Default ordering not working on %s" % name)
+                                    "Default ordering not working on %s"
+                                    " '%s' should be <= '%s'" %
+                                    (name, row_one, row_two))
 
             # Test the column ordering and filtering functionality
             for column in table.columns:
@@ -580,7 +406,9 @@ class ViewTests(TestCase):
 
                     self.assertTrue(row_one <= row_two,
                                     "Ascending sort applied but row 0 is less "
-                                    "than row 1")
+                                    "than row 1 %s %s " %
+                                    (column['field_name'], name))
+
 
                     descending = get_data(table_cls(),
                                           {"orderby" :
@@ -591,7 +419,8 @@ class ViewTests(TestCase):
 
                     self.assertTrue(row_one >= row_two,
                                     "Descending sort applied but row 0 is "
-                                    "greater than row 1")
+                                    "greater than row 1 %s %s" %
+                                    (column['field_name'], name))
 
                     # If the two start rows are the same we haven't actually
                     # changed the order
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] toaster: PackagesTable show only installed packages
  2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
                   ` (2 preceding siblings ...)
  2016-02-16 19:19 ` [PATCH 3/5] toaster: toastergui unit tests convert to use fixtures Michael Wood
@ 2016-02-16 19:19 ` Michael Wood
  2016-02-16 19:19 ` [PATCH 5/5] toaster: toastergui Fix invalid char test and implementation Michael Wood
  2016-02-17 17:29 ` [PATCH 0/5] mysql migrations and unittests fixes Barros Pena, Belen
  5 siblings, 0 replies; 10+ messages in thread
From: Michael Wood @ 2016-02-16 19:19 UTC (permalink / raw)
  To: toaster

When showing the package list for the image recipe details only show the
packages which are installed in the image rather than all the packages
which are produced.

[YOCTO #9108]

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/toastergui/tables.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index 5a589d3..c0ad2b7 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -654,7 +654,9 @@ class PackagesTable(ToasterTable):
                                       ).last()
 
         if target:
-            return target.build.package_set.all()
+            pkgs = target.target_installed_package_set.values_list('package',
+                                                                   flat=True)
+            return Package.objects.filter(pk__in=pkgs)
 
         # Target/recipe never successfully built so empty queryset
         return Package.objects.none()
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] toaster: toastergui Fix invalid char test and implementation
  2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
                   ` (3 preceding siblings ...)
  2016-02-16 19:19 ` [PATCH 4/5] toaster: PackagesTable show only installed packages Michael Wood
@ 2016-02-16 19:19 ` Michael Wood
  2016-02-17 17:29 ` [PATCH 0/5] mysql migrations and unittests fixes Barros Pena, Belen
  5 siblings, 0 replies; 10+ messages in thread
From: Michael Wood @ 2016-02-16 19:19 UTC (permalink / raw)
  To: toaster

This test was passing but because the assertion was the wrong way round
and should have expected the first one to pass and second one to fail,
in reality both were failing as the method for checking the invalid char
was incorrect.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/toastergui/tests.py | 2 +-
 bitbake/lib/toaster/toastergui/views.py | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 1b6e78d..4e420ea 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -155,7 +155,7 @@ class ViewTests(TestCase):
         response = self.client.post(reverse('xhr_importlayer'), args)
         data = json.loads(response.content)
         self.assertEqual(response.status_code, 200)
-        self.assertNotEqual(data["error"], "ok")
+        self.assertEqual(data["error"], "ok")
 
         #Test to verify import of a layer successful
         args['name'] = "meta-oe"
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index dfa256e..13489af 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2185,8 +2185,11 @@ if True:
         layers_added = [];
 
         # Rudimentary check for any possible html tags
-        if "<" in request.POST:
-          return HttpResponse(jsonfilter({"error": "Invalid character <"}), content_type = "application/json")
+        for val in request.POST.values():
+            if "<" in val:
+                return HttpResponse(jsonfilter(
+                    {"error": "Invalid character <"}),
+                    content_type="application/json")
 
         prj = Project.objects.get(pk=request.POST['project_id'])
 
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] mysql migrations and unittests fixes
  2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
                   ` (4 preceding siblings ...)
  2016-02-16 19:19 ` [PATCH 5/5] toaster: toastergui Fix invalid char test and implementation Michael Wood
@ 2016-02-17 17:29 ` Barros Pena, Belen
  2016-02-18  9:27   ` Barros Pena, Belen
  5 siblings, 1 reply; 10+ messages in thread
From: Barros Pena, Belen @ 2016-02-17 17:29 UTC (permalink / raw)
  To: Wood, Michael G, toaster



On 16/02/2016 20:19, "toaster-bounces@yoctoproject.org on behalf of
Michael Wood" <toaster-bounces@yoctoproject.org on behalf of
michael.g.wood@intel.com> wrote:

>This series contains a clean up of the database migrations to fix the
>issue that was preventing Toaster from starting up when using mysql
>backend.
>See https://bugzilla.yoctoproject.org/show_bug.cgi?id=9116

I tried this with a clean sqlite database. I started toaster, created a
project with the master release and started a build for
core-image-minimal. The build got stuck towards the end. The
toaster_ui.log shows this error:

NOTE: Tasks Summary: Attempted 2103 tasks of which 2095 didn't need to be
rerun and 2 failed.
NOTE: Logging error 2: {'lineno': 88, 'message': "Execution of event
handler 'toaster_buildhistory_dump' failed", 'pathname':
'/home/yocto/master/bitbake/lib/bb/event.py', 'build': <Build: 1
migrations test (Release master (master), BBV master (Branch: master))
core-image-minimal>, 'level': 2}
ERROR: Execution of event handler 'toaster_buildhistory_dump' failed
Traceback (most recent call last):
  File 
"/home/yocto/master/_toaster_clones/_git___git.yoctoproject.org_poky_master
/meta/classes/toaster.bbclass", line 315, in
toaster_buildhistory_dump(e=<bb.event.BuildCompleted object at
0x7fafc8a35590>):
     
    >            with open("%s/files-in-image.txt" % installed_img_path,
"r") as fin:
                     for line in fin:
IOError: [Errno 2] No such file or directory:
'/home/yocto/master/build/buildhistory/images/qemux86/glibc/core-image-mini
mal/files-in-image.txt'


Cheers

Belén

>
>After fixing these migrations and getting Toaster to start up properly
>using mysql backend a number of unittests failed due to differences in
>testing on sqlite.
>To remove these differences I've changed the data that was in the setUp
>to be more agnostic and added .lower() where needed to make sure the
>orderby re-ordering in the same way. I also took this opportunitiy to
>convert the toastergui unit tests to use a django fixture making it
>easier to load the database state for testing.
>
>Bugs fixed discovered by fixing the unit tests are:
> - toaster: SoftwareRecipesTable apply default order_by
> - toaster: toastergui Fix invalid char test and implementation
>and one already reported
> - toaster: PackagesTable show only installed packages
>
>[note files deleted and added in this series]
>
>Michael Wood (5):
>  toaster: orm migrations Sort out migrations mess
>  toaster: SoftwareRecipesTable apply default order_by
>  toaster: toastergui unit tests convert to use fixtures
>  toaster: PackagesTable show only installed packages
>  toaster: toastergui Fix invalid char test and implementation
>
> bitbake/lib/toaster/orm/migrations/0001_initial.py |  26 --
> .../orm/migrations/0002_auto_20151210_1209.py      |  41 --
> .../orm/migrations/0002_auto_20151223_1528.py      |  27 --
> .../orm/migrations/0002_customimagerecipe.py       |  24 ++
> .../orm/migrations/0003_customimagepackage.py      |   2 +-
> bitbake/lib/toaster/orm/migrations/0004_merge.py   |  15 -
> .../lib/toaster/orm/migrations/0004_provides.py    |  27 ++
> .../orm/migrations/0005_auto_20160118_1055.py      |  19 -
> .../0006_customimagerecipe_last_updated.py         |  19 -
> .../fixtures/toastergui-unittest-data.xml          | 446
>+++++++++++++++++++++
> bitbake/lib/toaster/toastergui/tables.py           |   5 +-
> bitbake/lib/toaster/toastergui/tests.py            | 257 ++----------
> bitbake/lib/toaster/toastergui/views.py            |   7 +-
> 13 files changed, 550 insertions(+), 365 deletions(-)
> delete mode 100644
>bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
> delete mode 100644
>bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
> create mode 100644
>bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
> delete mode 100644 bitbake/lib/toaster/orm/migrations/0004_merge.py
> create mode 100644 bitbake/lib/toaster/orm/migrations/0004_provides.py
> delete mode 100644
>bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
> delete mode 100644
>bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py
> create mode 100644
>bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
>
>-- 
>2.5.0
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] mysql migrations and unittests fixes
  2016-02-17 17:29 ` [PATCH 0/5] mysql migrations and unittests fixes Barros Pena, Belen
@ 2016-02-18  9:27   ` Barros Pena, Belen
  2016-02-19  5:21     ` Brian Avery
  0 siblings, 1 reply; 10+ messages in thread
From: Barros Pena, Belen @ 2016-02-18  9:27 UTC (permalink / raw)
  To: Wood, Michael G, toaster



On 17/02/2016 18:29, "toaster-bounces@yoctoproject.org on behalf of Barros
Pena, Belen" <toaster-bounces@yoctoproject.org on behalf of
belen.barros.pena@intel.com> wrote:

>
>
>On 16/02/2016 20:19, "toaster-bounces@yoctoproject.org on behalf of
>Michael Wood" <toaster-bounces@yoctoproject.org on behalf of
>michael.g.wood@intel.com> wrote:
>
>>This series contains a clean up of the database migrations to fix the
>>issue that was preventing Toaster from starting up when using mysql
>>backend.
>>See https://bugzilla.yoctoproject.org/show_bug.cgi?id=9116

I gave it another go. I pushed the branch I used before to

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=bbarrosp/test
/michaelw/mysql-migration


It looks the same to me as

poky-contrib/bavery/test/michaelw/mysql-migration


But just in case you want to look at it.

I then checked out poky-contrib/bavery/test/michaelw/mysql-migration and
ran a build, but it failed with the same error. So I removed the whole
build dir and tried once more. Building master worked this time, and the
series seems to fix 9108. But there are a couple of funny notes and errors
in the toaster_ui.log file, which I've uploaded to

https://drive.google.com/file/d/0B1KD45-8S-9FdDdOTTlJM0xpVFE/view?usp=shari
ng

The builds that succeeded are the last 2 in that log.

Cheers

Belén


>
>I tried this with a clean sqlite database. I started toaster, created a
>project with the master release and started a build for
>core-image-minimal. The build got stuck towards the end. The
>toaster_ui.log shows this error:
>
>NOTE: Tasks Summary: Attempted 2103 tasks of which 2095 didn't need to be
>rerun and 2 failed.
>NOTE: Logging error 2: {'lineno': 88, 'message': "Execution of event
>handler 'toaster_buildhistory_dump' failed", 'pathname':
>'/home/yocto/master/bitbake/lib/bb/event.py', 'build': <Build: 1
>migrations test (Release master (master), BBV master (Branch: master))
>core-image-minimal>, 'level': 2}
>ERROR: Execution of event handler 'toaster_buildhistory_dump' failed
>Traceback (most recent call last):
>  File 
>"/home/yocto/master/_toaster_clones/_git___git.yoctoproject.org_poky_maste
>r
>/meta/classes/toaster.bbclass", line 315, in
>toaster_buildhistory_dump(e=<bb.event.BuildCompleted object at
>0x7fafc8a35590>):
>     
>    >            with open("%s/files-in-image.txt" % installed_img_path,
>"r") as fin:
>                     for line in fin:
>IOError: [Errno 2] No such file or directory:
>'/home/yocto/master/build/buildhistory/images/qemux86/glibc/core-image-min
>i
>mal/files-in-image.txt'
>
>
>Cheers
>
>Belén
>
>>
>>After fixing these migrations and getting Toaster to start up properly
>>using mysql backend a number of unittests failed due to differences in
>>testing on sqlite.
>>To remove these differences I've changed the data that was in the setUp
>>to be more agnostic and added .lower() where needed to make sure the
>>orderby re-ordering in the same way. I also took this opportunitiy to
>>convert the toastergui unit tests to use a django fixture making it
>>easier to load the database state for testing.
>>
>>Bugs fixed discovered by fixing the unit tests are:
>> - toaster: SoftwareRecipesTable apply default order_by
>> - toaster: toastergui Fix invalid char test and implementation
>>and one already reported
>> - toaster: PackagesTable show only installed packages
>>
>>[note files deleted and added in this series]
>>
>>Michael Wood (5):
>>  toaster: orm migrations Sort out migrations mess
>>  toaster: SoftwareRecipesTable apply default order_by
>>  toaster: toastergui unit tests convert to use fixtures
>>  toaster: PackagesTable show only installed packages
>>  toaster: toastergui Fix invalid char test and implementation
>>
>> bitbake/lib/toaster/orm/migrations/0001_initial.py |  26 --
>> .../orm/migrations/0002_auto_20151210_1209.py      |  41 --
>> .../orm/migrations/0002_auto_20151223_1528.py      |  27 --
>> .../orm/migrations/0002_customimagerecipe.py       |  24 ++
>> .../orm/migrations/0003_customimagepackage.py      |   2 +-
>> bitbake/lib/toaster/orm/migrations/0004_merge.py   |  15 -
>> .../lib/toaster/orm/migrations/0004_provides.py    |  27 ++
>> .../orm/migrations/0005_auto_20160118_1055.py      |  19 -
>> .../0006_customimagerecipe_last_updated.py         |  19 -
>> .../fixtures/toastergui-unittest-data.xml          | 446
>>+++++++++++++++++++++
>> bitbake/lib/toaster/toastergui/tables.py           |   5 +-
>> bitbake/lib/toaster/toastergui/tests.py            | 257 ++----------
>> bitbake/lib/toaster/toastergui/views.py            |   7 +-
>> 13 files changed, 550 insertions(+), 365 deletions(-)
>> delete mode 100644
>>bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
>> delete mode 100644
>>bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
>> create mode 100644
>>bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
>> delete mode 100644 bitbake/lib/toaster/orm/migrations/0004_merge.py
>> create mode 100644 bitbake/lib/toaster/orm/migrations/0004_provides.py
>> delete mode 100644
>>bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
>> delete mode 100644
>>bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py
>> create mode 100644
>>bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
>>
>>-- 
>>2.5.0
>>
>>-- 
>>_______________________________________________
>>toaster mailing list
>>toaster@yoctoproject.org
>>https://lists.yoctoproject.org/listinfo/toaster
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] mysql migrations and unittests fixes
  2016-02-18  9:27   ` Barros Pena, Belen
@ 2016-02-19  5:21     ` Brian Avery
  0 siblings, 0 replies; 10+ messages in thread
From: Brian Avery @ 2016-02-19  5:21 UTC (permalink / raw)
  To: Barros Pena, Belen; +Cc: toaster

Hi!
Turns out I can replicate the error. It was true on master as well as
on this set of patches so I pushed these patches into bitbake-devel.
Ive filed a bug on it
https://bugzilla.yoctoproject.org/show_bug.cgi?id=9142.
-b

p.s. Thanks Belén for catching this!!

On Thu, Feb 18, 2016 at 1:27 AM, Barros Pena, Belen
<belen.barros.pena@intel.com> wrote:
>
>
> On 17/02/2016 18:29, "toaster-bounces@yoctoproject.org on behalf of Barros
> Pena, Belen" <toaster-bounces@yoctoproject.org on behalf of
> belen.barros.pena@intel.com> wrote:
>
>>
>>
>>On 16/02/2016 20:19, "toaster-bounces@yoctoproject.org on behalf of
>>Michael Wood" <toaster-bounces@yoctoproject.org on behalf of
>>michael.g.wood@intel.com> wrote:
>>
>>>This series contains a clean up of the database migrations to fix the
>>>issue that was preventing Toaster from starting up when using mysql
>>>backend.
>>>See https://bugzilla.yoctoproject.org/show_bug.cgi?id=9116
>
> I gave it another go. I pushed the branch I used before to
>
> http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=bbarrosp/test
> /michaelw/mysql-migration
>
>
> It looks the same to me as
>
> poky-contrib/bavery/test/michaelw/mysql-migration
>
>
> But just in case you want to look at it.
>
> I then checked out poky-contrib/bavery/test/michaelw/mysql-migration and
> ran a build, but it failed with the same error. So I removed the whole
> build dir and tried once more. Building master worked this time, and the
> series seems to fix 9108. But there are a couple of funny notes and errors
> in the toaster_ui.log file, which I've uploaded to
>
> https://drive.google.com/file/d/0B1KD45-8S-9FdDdOTTlJM0xpVFE/view?usp=shari
> ng
>
> The builds that succeeded are the last 2 in that log.
>
> Cheers
>
> Belén
>
>
>>
>>I tried this with a clean sqlite database. I started toaster, created a
>>project with the master release and started a build for
>>core-image-minimal. The build got stuck towards the end. The
>>toaster_ui.log shows this error:
>>
>>NOTE: Tasks Summary: Attempted 2103 tasks of which 2095 didn't need to be
>>rerun and 2 failed.
>>NOTE: Logging error 2: {'lineno': 88, 'message': "Execution of event
>>handler 'toaster_buildhistory_dump' failed", 'pathname':
>>'/home/yocto/master/bitbake/lib/bb/event.py', 'build': <Build: 1
>>migrations test (Release master (master), BBV master (Branch: master))
>>core-image-minimal>, 'level': 2}
>>ERROR: Execution of event handler 'toaster_buildhistory_dump' failed
>>Traceback (most recent call last):
>>  File
>>"/home/yocto/master/_toaster_clones/_git___git.yoctoproject.org_poky_maste
>>r
>>/meta/classes/toaster.bbclass", line 315, in
>>toaster_buildhistory_dump(e=<bb.event.BuildCompleted object at
>>0x7fafc8a35590>):
>>
>>    >            with open("%s/files-in-image.txt" % installed_img_path,
>>"r") as fin:
>>                     for line in fin:
>>IOError: [Errno 2] No such file or directory:
>>'/home/yocto/master/build/buildhistory/images/qemux86/glibc/core-image-min
>>i
>>mal/files-in-image.txt'
>>
>>
>>Cheers
>>
>>Belén
>>
>>>
>>>After fixing these migrations and getting Toaster to start up properly
>>>using mysql backend a number of unittests failed due to differences in
>>>testing on sqlite.
>>>To remove these differences I've changed the data that was in the setUp
>>>to be more agnostic and added .lower() where needed to make sure the
>>>orderby re-ordering in the same way. I also took this opportunitiy to
>>>convert the toastergui unit tests to use a django fixture making it
>>>easier to load the database state for testing.
>>>
>>>Bugs fixed discovered by fixing the unit tests are:
>>> - toaster: SoftwareRecipesTable apply default order_by
>>> - toaster: toastergui Fix invalid char test and implementation
>>>and one already reported
>>> - toaster: PackagesTable show only installed packages
>>>
>>>[note files deleted and added in this series]
>>>
>>>Michael Wood (5):
>>>  toaster: orm migrations Sort out migrations mess
>>>  toaster: SoftwareRecipesTable apply default order_by
>>>  toaster: toastergui unit tests convert to use fixtures
>>>  toaster: PackagesTable show only installed packages
>>>  toaster: toastergui Fix invalid char test and implementation
>>>
>>> bitbake/lib/toaster/orm/migrations/0001_initial.py |  26 --
>>> .../orm/migrations/0002_auto_20151210_1209.py      |  41 --
>>> .../orm/migrations/0002_auto_20151223_1528.py      |  27 --
>>> .../orm/migrations/0002_customimagerecipe.py       |  24 ++
>>> .../orm/migrations/0003_customimagepackage.py      |   2 +-
>>> bitbake/lib/toaster/orm/migrations/0004_merge.py   |  15 -
>>> .../lib/toaster/orm/migrations/0004_provides.py    |  27 ++
>>> .../orm/migrations/0005_auto_20160118_1055.py      |  19 -
>>> .../0006_customimagerecipe_last_updated.py         |  19 -
>>> .../fixtures/toastergui-unittest-data.xml          | 446
>>>+++++++++++++++++++++
>>> bitbake/lib/toaster/toastergui/tables.py           |   5 +-
>>> bitbake/lib/toaster/toastergui/tests.py            | 257 ++----------
>>> bitbake/lib/toaster/toastergui/views.py            |   7 +-
>>> 13 files changed, 550 insertions(+), 365 deletions(-)
>>> delete mode 100644
>>>bitbake/lib/toaster/orm/migrations/0002_auto_20151210_1209.py
>>> delete mode 100644
>>>bitbake/lib/toaster/orm/migrations/0002_auto_20151223_1528.py
>>> create mode 100644
>>>bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
>>> delete mode 100644 bitbake/lib/toaster/orm/migrations/0004_merge.py
>>> create mode 100644 bitbake/lib/toaster/orm/migrations/0004_provides.py
>>> delete mode 100644
>>>bitbake/lib/toaster/orm/migrations/0005_auto_20160118_1055.py
>>> delete mode 100644
>>>bitbake/lib/toaster/orm/migrations/0006_customimagerecipe_last_updated.py
>>> create mode 100644
>>>bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
>>>
>>>--
>>>2.5.0
>>>
>>>--
>>>_______________________________________________
>>>toaster mailing list
>>>toaster@yoctoproject.org
>>>https://lists.yoctoproject.org/listinfo/toaster
>>
>>--
>>_______________________________________________
>>toaster mailing list
>>toaster@yoctoproject.org
>>https://lists.yoctoproject.org/listinfo/toaster
>
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/5] toaster: PackagesTable show only installed packages
  2016-02-19  5:21 ` [PATCH 0/5] toaster: fix mysql migrations and add django test fixture brian avery
@ 2016-02-19  5:21   ` brian avery
  0 siblings, 0 replies; 10+ messages in thread
From: brian avery @ 2016-02-19  5:21 UTC (permalink / raw)
  To: bitbake-devel

From: Michael Wood <michael.g.wood@intel.com>

When showing the package list for the image recipe details only show the
packages which are installed in the image rather than all the packages
which are produced.

[YOCTO #9108]

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
---
 lib/toaster/toastergui/tables.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/toaster/toastergui/tables.py b/lib/toaster/toastergui/tables.py
index 5a589d3..c0ad2b7 100644
--- a/lib/toaster/toastergui/tables.py
+++ b/lib/toaster/toastergui/tables.py
@@ -654,7 +654,9 @@ class PackagesTable(ToasterTable):
                                       ).last()
 
         if target:
-            return target.build.package_set.all()
+            pkgs = target.target_installed_package_set.values_list('package',
+                                                                   flat=True)
+            return Package.objects.filter(pk__in=pkgs)
 
         # Target/recipe never successfully built so empty queryset
         return Package.objects.none()
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-02-19  5:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16 19:19 [PATCH 0/5] mysql migrations and unittests fixes Michael Wood
2016-02-16 19:19 ` [PATCH 1/5] toaster: orm migrations Sort out migrations mess Michael Wood
2016-02-16 19:19 ` [PATCH 2/5] toaster: SoftwareRecipesTable apply default order_by Michael Wood
2016-02-16 19:19 ` [PATCH 3/5] toaster: toastergui unit tests convert to use fixtures Michael Wood
2016-02-16 19:19 ` [PATCH 4/5] toaster: PackagesTable show only installed packages Michael Wood
2016-02-16 19:19 ` [PATCH 5/5] toaster: toastergui Fix invalid char test and implementation Michael Wood
2016-02-17 17:29 ` [PATCH 0/5] mysql migrations and unittests fixes Barros Pena, Belen
2016-02-18  9:27   ` Barros Pena, Belen
2016-02-19  5:21     ` Brian Avery
2016-02-19  5:21 [PATCH 1/5] toaster: orm migrations Sort out migrations mess brian avery
2016-02-19  5:21 ` [PATCH 0/5] toaster: fix mysql migrations and add django test fixture brian avery
2016-02-19  5:21   ` [PATCH 4/5] toaster: PackagesTable show only installed packages brian avery

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.