# Path: lib/terms.py
# def numeric_value_of_term(term):
# def is_valid_term(term):
# def split_term(term):
# def get_next_term(term):
# 
# Path: lib/constants.py
# CURRENT_TERM = os.environ["CURRENT_TERM"]  # e.g. 16S
# SUPPORT_EMAIL = "support@layuplist.com"
# REC_UPVOTE_REQ = 2
# OFFERINGS_THRESHOLD_FOR_TERM_UPDATE = int(
#     os.environ["OFFERINGS_THRESHOLD_FOR_TERM_UPDATE"])


from django.test import TestCase
from lib import terms, constants
import random
        self.assertTrue(
            term_data and
            term_data.group('year') == constants.CURRENT_TERM[:2] and
            term_data.group('term') == constants.CURRENT_TERM[2]
        )

    def test_numeric_value_of_term_returns_0_if_bad_term(self):
        self.assertEqual(terms.numeric_value_of_term(''), 0)
        self.assertEqual(terms.numeric_value_of_term('asd'), 0)
        self.assertEqual(terms.numeric_value_of_term('2001'), 0)
        self.assertEqual(terms.numeric_value_of_term('1s'), 0)
        self.assertEqual(terms.numeric_value_of_term('2016w'), 0)
        self.assertEqual(terms.numeric_value_of_term('fall'), 0)

    def test_numeric_value_of_term_ranks_terms_in_correct_order(self):
        correct_order = ['', '09w', '09S', '09X',
                         '12F', '14x', '15W', '16S', '20x']
        shuffled_data = list(correct_order)
        while correct_order == shuffled_data:
            random.shuffle(shuffled_data)
        sorted_data = sorted(
            shuffled_data, key=lambda term: terms.numeric_value_of_term(term))
        self.assertNotEqual(correct_order, shuffled_data)
        self.assertEqual(correct_order, sorted_data)

    def test_numeric_value_of_term_gives_expected_numeric_value(self):
        self.assertEqual(terms.numeric_value_of_term('16W'), 161)

    def test_is_valid_term_returns_false_if_in_future(self):
        next_year = int(terms.term_regex.match(

# Path: lib/terms.py
# def numeric_value_of_term(term):
# def is_valid_term(term):
# def split_term(term):
# def get_next_term(term):
# 
# Path: lib/constants.py
# CURRENT_TERM = os.environ["CURRENT_TERM"]  # e.g. 16S
# SUPPORT_EMAIL = "support@layuplist.com"
# REC_UPVOTE_REQ = 2
# OFFERINGS_THRESHOLD_FOR_TERM_UPDATE = int(
#     os.environ["OFFERINGS_THRESHOLD_FOR_TERM_UPDATE"])


# Path: apps/web/tests/lib_tests/test_terms.py
from django.test import TestCase
from lib import terms, constants
import random

        self.assertTrue(
            term_data and
            term_data.group('year') == constants.CURRENT_TERM[:2] and
            term_data.group('term') == constants.CURRENT_TERM[2]
        )

    def test_numeric_value_of_term_returns_0_if_bad_term(self):
        self.assertEqual(terms.numeric_value_of_term(''), 0)
        self.assertEqual(terms.numeric_value_of_term('asd'), 0)
        self.assertEqual(terms.numeric_value_of_term('2001'), 0)
        self.assertEqual(terms.numeric_value_of_term('1s'), 0)
        self.assertEqual(terms.numeric_value_of_term('2016w'), 0)
        self.assertEqual(terms.numeric_value_of_term('fall'), 0)

    def test_numeric_value_of_term_ranks_terms_in_correct_order(self):
        correct_order = ['', '09w', '09S', '09X',
                         '12F', '14x', '15W', '16S', '20x']
        shuffled_data = list(correct_order)
        while correct_order == shuffled_data:
            random.shuffle(shuffled_data)
        sorted_data = sorted(
            shuffled_data, key=lambda term: terms.numeric_value_of_term(term))
        self.assertNotEqual(correct_order, shuffled_data)
        self.assertEqual(correct_order, sorted_data)

    def test_numeric_value_of_term_gives_expected_numeric_value(self):
        self.assertEqual(terms.numeric_value_of_term('16W'), 161)

    def test_is_valid_term_returns_false_if_in_future(self):
        next_year = int(terms.term_regex.match(

            constants.CURRENT_TERM).group('year')) + 1