<commit_before>from StringIO import StringIO
from django.test import TestCase
from django.test.client import Client
from corehq.apps.app_manager.models import Application, APP_V1
from corehq.apps.app_manager.success_message import SuccessMessage
from corehq.apps.users.models import CommCareUser
from datetime import datetime, timedelta
from dimagi.utils.parsing import json_format_datetime
from receiver.xml import get_simple_response_xml, ResponseNature

submission_template = """<?xml version='1.0' ?>
<data xmlns="%(xmlns)s">
	<meta>
		<username>%(username)s</username>
		<userID>%(userID)s</userID>
	</meta>
</data>
"""

class SuccessMessageTest(TestCase):
    message = "Thanks $first_name ($name)! You have submitted $today forms today and $week forms since Monday."
    domain = "test"
    username = "danny"
    first_name = "Danny"
    last_name = "Roberts"
    password = "<PASSWORD>"
    xmlns = "http://dimagi.com/does_not_matter"
    tz = timedelta(hours=0)
    def setUp(self):
        couch_user = CommCareUser.create(self.domain, self.username, self.password)
        userID = couch_user.user_id
        couch_user.first_name = self.first_name
        couch_user.last_name = self.last_name
        couch_user.save()
        self.sm = SuccessMessage(self.message, userID, tz=self.tz)

        c = Client()

        app = Application.new_app(self.domain, "Test App", "en", application_version=APP_V1)
        app.new_module("Test Module", "en")
        form = app.new_form(0, "Test Form", "en")
        form.xmlns = self.xmlns
        app.success_message = {"en": self.message}
        app.save()

        def fake_form_submission(userID=userID, username=self.username, xmlns=self.xmlns, time=None):
            submission = submission_template % {
                "userID": userID,<commit_msg>fixed app_manager test<commit_after>from StringIO import StringIO
from django.test import TestCase
from django.test.client import Client
from corehq.apps.app_manager.models import Application, APP_V1
from corehq.apps.app_manager.success_message import SuccessMessage
from corehq.apps.users.models import CommCareUser
from datetime import datetime, timedelta
from dimagi.utils.parsing import json_format_datetime
from receiver.xml import get_simple_response_xml, ResponseNature

submission_template = """<?xml version='1.0' ?>
<data xmlns="%(xmlns)s">
	<meta>
		<username>%(username)s</username>
		<userID>%(userID)s</userID>
	</meta>
</data>
"""

class SuccessMessageTest(TestCase):
    message = "Thanks $first_name ($name)! You have submitted $today forms today and $week forms since Monday."
    domain = "test"
    username = "danny"
    first_name = "Danny"
    last_name = "Roberts"
    password = "<PASSWORD>"
    xmlns = "http://dimagi.com/does_not_matter"
    tz = timedelta(hours=0)
    def setUp(self):
        couch_user = CommCareUser.create(self.domain, self.username, self.password)
        userID = couch_user.user_id
        couch_user.first_name = self.first_name
        couch_user.last_name = self.last_name
        couch_user.save()
        self.sm = SuccessMessage(self.message, userID, tz=self.tz)

        c = Client()

        app = Application.new_app(self.domain, "Test App", application_version=APP_V1)
        app.new_module("Test Module", "en")
        form = app.new_form(0, "Test Form", "en")
        form.xmlns = self.xmlns
        app.success_message = {"en": self.message}
        app.save()

        def fake_form_submission(userID=userID, username=self.username, xmlns=self.xmlns, time=None):
            submission = submission_template % {
                "userID": userID,
{'fraction_non_alphanumeric': 0.11516155758077878, 'fraction_numerical': 0.0033140016570008283, 'mean_word_length': 3.667525773195876, 'pattern_counts': {'":': 4, '<': 23, '<?xml version=': 2, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 20}, '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': '3517041', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1129, 'n_words': 256}