<commit_before>from django.test import TestCase

from freezegun import freeze_time

from ...ditto.templatetags.ditto import display_time
from ...ditto.utils import datetime_now
from ..templatetags import flickr


class TakenTimeTestCase(TestCase):

    @freeze_time("2015-08-14 13:34:56", tz_offset=-8)
    def setUp(self):
        self.dt = datetime_now()

    def test_taken_time_0(self):
        "taken_time() with granularity 0"
        self.assertEqual(flickr.taken_time(self.dt, 0),
                'Taken at %s' % display_time(self.dt, True))

    def test_taken_time_4(self):
        "taken_time() with granularity 4"
        self.assertEqual(flickr.taken_time(self.dt, 4),
                        'Taken some time in August 2015')

    def test_taken_time_6(self):
        "taken_time() with granularity 6"
        self.assertEqual(flickr.taken_time(self.dt, 6),
                        'Taken some time in 2015')

    def test_taken_time_8(self):
        "taken_time() with granularity 8"
        self.assertEqual(flickr.taken_time(self.dt, 8),
                        'Taken circa 2015')

    def test_taken_time_9(self):
        "taken_time() with granularity 9"
        self.assertEqual(flickr.taken_time(self.dt, 9), '')


class PhotoLicenseTestCase(TestCase):

    def test_license_0(self):
        self.assertEqual(flickr.photo_license('0'), 'All Rights Reserved')

    def test_license_1(self):
        self.assertEqual(flickr.photo_license('1'),
            '<a href="https://creativecommons.org/licenses/by-nc-sa/2.0/" title="More about permissions">Attribution-NonCommercial-ShareAlike License</a>'
        )

    def test_license_99(self):
        self.assertEqual(flickr.photo_license('99'), '[missing]')


class PhotoSafetyLevelTestCase(TestCase):

    def test_safety_level_0(self):
        self.assertEqual(flickr.photo_safety_level(0), 'none')<commit_msg>Fix tests for taken_time templatetag<commit_after>from django.test import TestCase

from freezegun import freeze_time

from ...ditto.templatetags.ditto import display_time
from ...ditto.utils import datetime_now
from ..templatetags import flickr


class TakenTimeTestCase(TestCase):

    @freeze_time("2015-08-14 13:34:56", tz_offset=-8)
    def setUp(self):
        self.dt = datetime_now()

    def test_taken_time_0(self):
        "taken_time() with granularity 0"
        self.assertEqual(flickr.taken_time(self.dt, 0),
                        '%s' % display_time(self.dt, True))

    def test_taken_time_4(self):
        "taken_time() with granularity 4"
        self.assertEqual(flickr.taken_time(self.dt, 4),
                        'Some time in August 2015')

    def test_taken_time_6(self):
        "taken_time() with granularity 6"
        self.assertEqual(flickr.taken_time(self.dt, 6),
                        'Some time in 2015')

    def test_taken_time_8(self):
        "taken_time() with granularity 8"
        self.assertEqual(flickr.taken_time(self.dt, 8),
                        'Circa 2015')

    def test_taken_time_9(self):
        "taken_time() with granularity 9"
        self.assertEqual(flickr.taken_time(self.dt, 9), '')


class PhotoLicenseTestCase(TestCase):

    def test_license_0(self):
        self.assertEqual(flickr.photo_license('0'), 'All Rights Reserved')

    def test_license_1(self):
        self.assertEqual(flickr.photo_license('1'),
            '<a href="https://creativecommons.org/licenses/by-nc-sa/2.0/" title="More about permissions">Attribution-NonCommercial-ShareAlike License</a>'
        )

    def test_license_99(self):
        self.assertEqual(flickr.photo_license('99'), '[missing]')


class PhotoSafetyLevelTestCase(TestCase):

    def test_safety_level_0(self):
        self.assertEqual(flickr.photo_safety_level(0), 'none')
{'fraction_non_alphanumeric': 0.11630377057886351, 'fraction_numerical': 0.02867764206054169, 'mean_word_length': 3.0505376344086024, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '1068694', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1165, 'n_words': 228}