<commit_before>"""
Tests that grade by enrollment mode Hive table is created.
"""

import datetime
import logging
import os

from cStringIO import StringIO

from ddt import ddt, data
import pandas

from edx.analytics.tasks.insights.enrollments import EnrollmentSummaryRecord
from edx.analytics.tasks.tests.acceptance import AcceptanceTestCase
from edx.analytics.tasks.util.url import url_path_join

log = logging.getLogger(__name__)


class EnrollmentGradesAcceptanceTest(AcceptanceTestCase):
    """End to end test of the CourseGradeByModeDataTask."""

    CATALOG_DATE = '2016-09-08'
    INPUT_FILE = 'enrollment_trends_tracking.log'

    @classmethod
    def setUpClass(cls):
        cls.maxDiff = None

    def setUp(self):
        """Loads enrollment and course catalog fixtures."""
        super(EnrollmentAcceptanceTest, self).setUp()

        self.upload_tracking_log(self.INPUT_FILE, datetime.date(2014, 7, 30))
        self.execute_sql_fixture_file('load_auth_userprofile.sql')

        self.upload_file(
            os.path.join(self.data_dir, 'input', 'course_catalog.json'),
            url_path_join(self.warehouse_path, 'course_catalog_raw', 'dt={}'.format(self.CATALOG_DATE),
                          'course_catalog.json')
        )
        self.import_db.execute_sql_file(<commit_msg>TNL-6873 | Fix bug from acceptance test.<commit_after>"""
Tests that grade by enrollment mode Hive table is created.
"""

import datetime
import logging
import os

from cStringIO import StringIO

from ddt import ddt, data
import pandas

from edx.analytics.tasks.insights.enrollments import EnrollmentSummaryRecord
from edx.analytics.tasks.tests.acceptance import AcceptanceTestCase
from edx.analytics.tasks.util.url import url_path_join

log = logging.getLogger(__name__)


class EnrollmentGradesAcceptanceTest(AcceptanceTestCase):
    """End to end test of the CourseGradeByModeDataTask."""

    CATALOG_DATE = '2016-09-08'
    INPUT_FILE = 'enrollment_trends_tracking.log'

    @classmethod
    def setUpClass(cls):
        cls.maxDiff = None

    def setUp(self):
        """Loads enrollment and course catalog fixtures."""
        super(EnrollmentGradesAcceptanceTest, self).setUp()

        self.upload_tracking_log(self.INPUT_FILE, datetime.date(2014, 7, 30))
        self.execute_sql_fixture_file('load_auth_userprofile.sql')

        self.upload_file(
            os.path.join(self.data_dir, 'input', 'course_catalog.json'),
            url_path_join(self.warehouse_path, 'course_catalog_raw', 'dt={}'.format(self.CATALOG_DATE),
                          'course_catalog.json')
        )
        self.import_db.execute_sql_file(
{'fraction_non_alphanumeric': 0.09435392194012884, 'fraction_numerical': 0.012883668056081848, 'mean_word_length': 3.7058823529411766, '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': '6981481', 'n_tokens_mistral': 849, 'n_tokens_neox': 797, 'n_words': 172}