<commit_before>from django.test import TestCase
from django.conf import settings
from datetime import datetime, timedelta
from restclients.sws import SWS
from restclients.exceptions import DataFailureException

class SWSTestTerm(TestCase):
    def test_mock_data_fake_grading_window(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            sws = SWS()
            term = sws.get_current_term()

            now = datetime.now()

            self.assertEquals(term.is_grading_period_open(), True, "Grading period is open")

            deadline_diff = term.grade_submission_deadline - now

            # This rounds down to 0 days, so check by seconds :(
            hour_1 = 60 * 60
            hours_48 = 60 * 60 * 48
            self.assertEquals(deadline_diff.seconds > hour_1, True, "Deadline is in the future")
            self.assertEquals(deadline_diff.seconds < hours_48, True, "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True, "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True, "But not too far in the past")

            # Also test for Spring 2013, as that's the "current" quarter
            term = sws.get_term_by_year_and_quarter(2013, 'spring')

            now = datetime.now()

            self.assertEquals(term.is_grading_period_open(), True, "Grading period is open")

            deadline_diff = term.grade_submission_deadline - now

            # This rounds down to 0 days, so check by seconds :(
            hour_1 = 60 * 60
            hours_48 = 60 * 60 * 48
            self.assertEquals(deadline_diff.seconds > hour_1, True, "Deadline is in the future")
            self.assertEquals(deadline_diff.seconds < hours_48, True, "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True, "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True, "But not too far in the past")<commit_msg>Using total_seconds(), to make it so test runs after 4:00pm don't fail<commit_after>from django.test import TestCase
from django.conf import settings
from datetime import datetime, timedelta
from restclients.sws import SWS
from restclients.exceptions import DataFailureException

class SWSTestTerm(TestCase):
    def test_mock_data_fake_grading_window(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            sws = SWS()
            term = sws.get_current_term()

            now = datetime.now()

            self.assertEquals(term.is_grading_period_open(), True, "Grading period is open")

            deadline_diff = term.grade_submission_deadline - now

            # This rounds down to 0 days, so check by seconds :(
            hour_1 = 60 * 60
            hours_48 = 60 * 60 * 48

            self.assertEquals(deadline_diff.total_seconds() > hour_1, True, "Deadline is in the future")
            self.assertEquals(deadline_diff.seconds < hours_48, True, "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True, "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True, "But not too far in the past")

            # Also test for Spring 2013, as that's the "current" quarter
            term = sws.get_term_by_year_and_quarter(2013, 'spring')

            now = datetime.now()

            self.assertEquals(term.is_grading_period_open(), True, "Grading period is open")

            deadline_diff = term.grade_submission_deadline - now

            # This rounds down to 0 days, so check by seconds :(
            hour_1 = 60 * 60
            hours_48 = 60 * 60 * 48
            self.assertEquals(deadline_diff.total_seconds() > hour_1, True, "Deadline is in the future")
            self.assertEquals(deadline_diff.seconds < hours_48, True, "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True, "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True, "But not too far in the past")
{'fraction_non_alphanumeric': 0.07808265582655827, 'fraction_numerical': 0.01744579945799458, 'mean_word_length': 2.6028065893837704, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '95560', 'n_tokens_mistral': 1809, 'n_tokens_neox': 1668, 'n_words': 498}