<commit_before>import os

from django.conf import settings
from django.test import Client, TestCase
from django.core.urlresolvers import reverse

import views
from project.utils import StringIO


class MainPageTestCase(TestCase):
    def setUp(self):
        self.client = Client()

    def test_index(self):
        response = self.client.get(reverse(views.upload_data))
        self.assertEqual(response.status_code, 200)

    def test_log_parse(self):
        with open(os.path.join(settings.MEDIA_ROOT, "tests", "A_TON_A_A.log"), 'r') as f:
            data = {
                "myfiles": f,
                "option": "logparse",
            }
            response = self.client.post(reverse(views.upload_data), data)
            self.assertEqual(response.status_code, 200)
            results = response.content.split('\n')[1]
            expected = "A_TON_A_A.log,opt B3LYP/6-31g(d) geom=connectivity,-6.460873931,-1.31976745,41,0.0006,-567.1965205,---,0.35"
            self.assertEqual(results, expected)
<commit_msg>Add test for gjf reset parsing<commit_after>import os
import zipfile

from django.conf import settings
from django.test import Client, TestCase
from django.core.urlresolvers import reverse

import views
from project.utils import StringIO


class MainPageTestCase(TestCase):
    def setUp(self):
        self.client = Client()

    def test_index(self):
        response = self.client.get(reverse(views.upload_data))
        self.assertEqual(response.status_code, 200)

    def test_log_parse(self):
        with open(os.path.join(settings.MEDIA_ROOT, "tests", "A_TON_A_A.log"), 'r') as f:
            data = {
                "myfiles": f,
                "option": "logparse",
            }
            response = self.client.post(reverse(views.upload_data), data)
            self.assertEqual(response.status_code, 200)
            results = response.content.split('\n')[1]
            expected = "A_TON_A_A.log,opt B3LYP/6-31g(d) geom=connectivity,-6.460873931,-1.31976745,41,0.0006,-567.1965205,---,0.35"
            self.assertEqual(results, expected)

    def test_gjf_reset(self):
        base = os.path.join(settings.MEDIA_ROOT, "tests", "A_TON_A_A")
        with open(base + ".log", 'r') as log, open(base + ".gjf", 'r') as gjf:
            data = {
                "myfiles": log,
                "option": "gjfreset",
            }
            response = self.client.post(reverse(views.upload_data), data)
            self.assertEqual(response.status_code, 200)
            with StringIO(response.content) as f:
                with zipfile.ZipFile(f, "r") as zfile:
                    with zfile.open("A_TON_A_A.gjf") as f2:
                        self.assertEqual(f2.read(), gjf.read())

{'fraction_non_alphanumeric': 0.12467913458012468, 'fraction_numerical': 0.03850385038503851, 'mean_word_length': 2.4487989886219976, 'pattern_counts': {'":': 6, '<': 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': '6292918', 'n_tokens_mistral': 931, 'n_tokens_neox': 850, 'n_words': 169}