"""
Unit tests of the Dashboard application
"""

from django.test import TestCase
from django.db import IntegrityError

from launch_control.dashboard_app.models import (
        SoftwarePackage,
        )


class SoftwarePackageTestCase(TestCase):

    def test_creation_1(self):
        sw_package = SoftwarePackage.objects.create(name='libfoo', version='1.2.0')
        self.assertEqual(sw_package.name, 'libfoo')
        self.assertEqual(sw_package.version, '1.2.0')

    def test_uniqueness(self):
        SoftwarePackage.objects.create(name='a', version='0')
        self.assertRaises(IntegrityError, SoftwarePackage.objects.create,
                name='a', version='0')

@@ -113,16 +113,80 @@
 yError%0A%0A
+from launch_control.utils.call_helper import ObjectFactoryMixIn%0A
 from lau
@@ -302,18 +302,145 @@
 TestCase
-):
+, ObjectFactoryMixIn):%0A%0A    class Dummy:%0A        class SoftwarePackage:%0A            name = 'libfoo'%0A            version = '1.2.0'
 %0A%0A    de
@@ -471,16 +471,23 @@
 %0A       
+ dummy,
  sw_pack
@@ -496,69 +496,47 @@
 e = 
-SoftwarePackage.objects.create(name='libfoo', version='1.2.0'
+self.make_and_get_dummy(SoftwarePackage
 )%0A  
@@ -575,24 +575,26 @@
 e.name, 
-'libfoo'
+dummy.name
 )%0A      
@@ -632,23 +632,29 @@
 ersion, 
-'1.2.0'
+dummy.version
 )%0A%0A    d
@@ -691,171 +691,153 @@
     
-SoftwarePackage.objects.create(name='a', version='0')%0A        self.assertRaises(IntegrityError, SoftwarePackage.objects.create,%0A                name='a', version='0'
+pkg1 = self.make(SoftwarePackage)%0A        pkg1.save()%0A        pkg2 = self.make(SoftwarePackage)%0A        self.assertRaises(IntegrityError, pkg2.save
 )%0A

Update SoftwarePackageTestCase to use ObjectFactoryMixIn