<commit_before>"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".

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

from django.test import TestCase, Client
from lingcod.staticmap.models import *
from django.conf import settings
from django.conf.urls.defaults import *

#urlpatterns = patterns('',
# Example:
#    (r'/staticmap/', include('lingcod.staticmap.urls')),
#)


class StaticMapTest(TestCase):

    def testMapConfigPresent(self):
        """
        Check presence of initial MapConfig
        """
        self.assertTrue(MapConfig.objects.count() > 0)

    def testDefaultMap(self):
        """
        test default staticmap image response
        """
        response = self.client.get('/staticmap/default/', {})
        self.assertEquals(response.status_code, 200)
        
    def testRedirectDefault(self):
        """
        test the redirection of staticmap without map name specified
        """
        response = self.client.get('/staticmap/', {})
        self.assertEquals(response.status_code, 301)

   <commit_msg>Mapnik doesn't release db connection so test db can't be deleted. Commenting out map test for now ... see https://trac.mapnik.org/ticket/434<commit_after>"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".

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

from django.test import TestCase, Client
from lingcod.staticmap.models import *
from django.conf import settings
from django.conf.urls.defaults import *

#urlpatterns = patterns('',
# Example:
#    (r'/staticmap/', include('lingcod.staticmap.urls')),
#)


class StaticMapTest(TestCase):

    def testMapConfigPresent(self):
        """
        Check presence of initial MapConfig
        """
        self.assertTrue(MapConfig.objects.count() > 0)

#TODO: This test works but causes mapnik to open a persistent database connection
#The idle connection prevents the tests from completing by holding onto connection
#which prevents the test db from being dropped.
# See: https://trac.mapnik.org/ticket/434
#    def testDefaultMap(self):
#        """
#        test default staticmap image response
#        """
#        response = self.client.get('/staticmap/default/', {})
#        self.assertEquals(response.status_code, 200)
        
    def testRedirectDefault(self):
        """
        test the redirection of staticmap without map name specified
        """
        response = self.client.get('/staticmap/', {})
        self.assertEquals(response.status_code, 301)

   
{'fraction_non_alphanumeric': 0.10536113179448994, 'fraction_numerical': 0.007446016381236039, 'mean_word_length': 3.1788491446345257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7527069', 'n_tokens_mistral': 737, 'n_tokens_neox': 705, 'n_words': 231}