<commit_before>"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase


class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 2)<commit_msg>Unit tests for some of the new Model logic introduced in the last commit<commit_after>from django.test import TestCase
from models import get_asset, Asset, HtmlAsset, HtmlAssetTranslation

class AssetModelTest(TestCase):
    def test_subclass(self):
        """ Test that Asset.subclass() returns the subclass of an Asset instance """
        asset = HtmlAsset()
        asset.save()
        translation = HtmlAssetTranslation(title="Test", asset=asset)
        translation.save()
        retrieved_asset = Asset.objects.get(pk=asset.pk)
        self.assertEqual(retrieved_asset.subclass(), asset)
        self.assertEqual(retrieved_asset.subclass().__class__.__name__, 'HtmlAsset')

    def test_license_name(self):
        asset = HtmlAsset(license='CC BY')
        asset.save()
        translation = HtmlAssetTranslation(title="Test", asset=asset)
        translation.save()
        self.assertEqual(asset.license_name(), 'Attribution Creative Commons')

class AssetApiTest(TestCase):
    def test_get_asset_return_subclass(self):
        """ Test that get_asset() returns the subclass of an Asset instance """
        asset = HtmlAsset()
        asset.save()
        translation = HtmlAssetTranslation(title="Test", asset=asset)
        translation.save()
        retrieved_asset = get_asset(asset_id=asset.asset_id)
        self.assertEqual(retrieved_asset, asset)
        self.assertEqual(retrieved_asset.__class__.__name__, 'HtmlAsset')
{'fraction_non_alphanumeric': 0.09665226781857451, 'fraction_numerical': 0.0032397408207343412, 'mean_word_length': 3.552825552825553, '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': '1979720', 'n_tokens_mistral': 513, 'n_tokens_neox': 487, 'n_words': 136}