from datetime import timedelta, date

from core.factories import UserFactory
from core.tests.base_test import SkillboxTestCase
from users.models import User


class LicenseExpiredTestCase(SkillboxTestCase):
    def setUp(self) -> None:
        self.user = UserFactory(username='some_user')

    def test_license_expired(self):
        self.user.license_expiry_date = date.today() - timedelta(days=1)
        self.user.save()
        self.assertTrue(self.user.get_license_status(), User.LICENSE_EXPIRED)

    def test_license_valid(self):
        self.user.license_expiry_date = date.today() + timedelta(days=1)
        self.user.save()
        self.assertTrue(self.user.get_license_status(), User.LICENSE_VALID)

    def test_license_none(self):
        self.assertTrue(self.user.get_license_status(), User.LICENSE_NONE)
