<commit_before>"""
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')<commit_msg>Update SoftwarePackageTestCase to use ObjectFactoryMixIn<commit_after>"""
Unit tests of the Dashboard application
"""

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

from launch_control.utils.call_helper import ObjectFactoryMixIn
from launch_control.dashboard_app.models import (
        SoftwarePackage,
        )


class SoftwarePackageTestCase(TestCase, ObjectFactoryMixIn):

    class Dummy:
        class SoftwarePackage:
            name = 'libfoo'
            version = '1.2.0'

    def test_creation_1(self):
        dummy, sw_package = self.make_and_get_dummy(SoftwarePackage)
        self.assertEqual(sw_package.name, dummy.name)
        self.assertEqual(sw_package.version, dummy.version)

    def test_uniqueness(self):
        pkg1 = self.make(SoftwarePackage)
        pkg1.save()
        pkg2 = self.make(SoftwarePackage)
        self.assertRaises(IntegrityError, pkg2.save)
{'fraction_non_alphanumeric': 0.0934984520123839, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 3.5779036827195467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6799243', 'n_tokens_mistral': 467, 'n_tokens_neox': 451, 'n_words': 93}