'Tests that emails can be sent to a specific track. Also checks that
emails can be sent to an expired track (EDUCATOR-364)'

@ddt.data(datetime.datetime(1999, 1, 1), datetime.datetime(datetime.MAXYEAR, 1, 1))
def test_track_target(self, expiration_datetime):

    course = CourseFactory.create()
    course_id = course.id
    sender = UserFactory.create()
    to_option = 'track:test'
    subject = 'dummy    subject'
    html_message = '<html>dummy    message</html>'
    CourseMode.objects.create(mode_slug='test', mode_display_name='Test', course_id=course_id, expiration_datetime=expiration_datetime)
    email = CourseEmail.create(course_id, sender, [to_option], subject, html_message)
    self.assertEqual(len(email.targets.all()), 1)
    target = email.targets.all()[0]
    self.assertEqual(target.target_type, SEND_TO_TRACK)
    self.assertEqual(target.short_display(), 'track-test')
    self.assertEqual(target.long_display(), 'Course    mode:    Test,    Currencies:    usd')
