예제 #1
0
 def setUp(self):
     self.aa = AffilFactory(
         name='t1.y2016.s001.cf1002.scnc.st.course:columbia.edu')
예제 #2
0
class AffilTest(TestCase):
    def setUp(self):
        self.aa = AffilFactory(
            name='t1.y2016.s001.cf1002.scnc.st.course:columbia.edu')

    def test_is_valid_from_factory(self):
        self.aa.full_clean()

    def test_str(self):
        self.assertEqual(smart_text(self.aa), self.aa.name)

    def test_past_present_future(self):
        with freeze_time('2012-01-14'):
            self.assertEqual(self.aa.past_present_future, 1)
        with freeze_time('2015-01-14'):
            self.assertEqual(self.aa.past_present_future, 1)
        with freeze_time('2015-08-15'):
            self.assertEqual(self.aa.past_present_future, 1)
        with freeze_time('2015-12-15'):
            self.assertEqual(self.aa.past_present_future, 1)
        with freeze_time('2016-01-14'):
            self.assertEqual(self.aa.past_present_future, 0)
        with freeze_time('2016-04-26'):
            self.assertEqual(self.aa.past_present_future, 0)
        with freeze_time('2016-06-04'):
            self.assertEqual(self.aa.past_present_future, -1)
        with freeze_time('2017-01-14'):
            self.assertEqual(self.aa.past_present_future, -1)
        with freeze_time('2017-03-30'):
            self.assertEqual(self.aa.past_present_future, -1)
        with freeze_time('2017-10-03'):
            self.assertEqual(self.aa.past_present_future, -1)
        with freeze_time('2017-12-03'):
            self.assertEqual(self.aa.past_present_future, -1)

        aa = AffilFactory(
            name='t2.y2016.s001.cf1002.scnc.st.course:columbia.edu')
        with freeze_time('2016-01-14'):
            self.assertEqual(aa.past_present_future, 1)
        with freeze_time('2016-04-26'):
            self.assertEqual(aa.past_present_future, 1)
        with freeze_time('2016-08-12'):
            self.assertEqual(aa.past_present_future, 0)
        with freeze_time('2017-12-03'):
            self.assertEqual(aa.past_present_future, -1)

        aa = AffilFactory(
            name='t3.y2016.s001.cf1002.scnc.st.course:columbia.edu')
        with freeze_time('2016-01-14'):
            self.assertEqual(aa.past_present_future, 1)
        with freeze_time('2016-04-26'):
            self.assertEqual(aa.past_present_future, 1)
        with freeze_time('2016-10-02'):
            self.assertEqual(aa.past_present_future, 0)
        with freeze_time('2017-12-03'):
            self.assertEqual(aa.past_present_future, -1)

        aa = AffilFactory(name='bogus affil string')
        self.assertEqual(aa.past_present_future, None)

    def test_courseworks_name(self):
        self.assertEqual(
            self.aa.courseworks_name,
            'CUcourse_SCNCf1002_001_2016_1')

    def test_coursedirectory_name(self):
        self.assertEqual(
            self.aa.coursedirectory_name,
            '20161SCNC1002F001')

    def test_shortname(self):
        self.assertEqual(self.aa.shortname, 'SCNC1002')

    def test_is_faculty(self):
        self.assertEqual(self.aa.is_faculty, False)

        aa = AffilFactory(
            name='t1.y2016.s002.cf1402.scnc.fc.course:columbia.edu')
        self.assertEqual(aa.is_faculty, True)

    def test_get_course(self):
        self.assertIsNone(self.aa.get_course())