# Path: sitegate/models.py
# class InvitationCode(InheritedModel, ModelWithCode):
# 
#     creator = models.ForeignKey(
#         USER_MODEL, related_name='creators', verbose_name=_('Creator'), on_delete=models.CASCADE)
# 
#     acceptor = models.ForeignKey(
#         USER_MODEL, related_name='acceptors', verbose_name=_('Acceptor'), null=True, blank=True,
#         editable=False, on_delete=models.CASCADE)
# 
#     class Meta:
#         verbose_name = _('Invitation code')
#         verbose_name_plural = _('Invitation codes')
# 
#     class Fields:
#         code = _('Invitation code')
#         expired = {'help_text': _('Visitors won\'t be able to sign up with an expired code.')}
# 
#     @classmethod
#     def add(cls, creator: 'User') -> 'InvitationCode':
#         new_code = cls(creator=creator)
#         new_code.save(force_insert=True)
#         return new_code
# 
#     @classmethod
#     def accept(cls, code: str, acceptor: 'User'):
#         return cls.objects.filter(code=code).update(acceptor=acceptor, expired=True, time_accepted=timezone.now())


from sitegate.models import InvitationCode


def test_generate_code(user):
    assert InvitationCode.generate_code()


def test_add(user):

# Path: sitegate/models.py
# class InvitationCode(InheritedModel, ModelWithCode):
# 
#     creator = models.ForeignKey(
#         USER_MODEL, related_name='creators', verbose_name=_('Creator'), on_delete=models.CASCADE)
# 
#     acceptor = models.ForeignKey(
#         USER_MODEL, related_name='acceptors', verbose_name=_('Acceptor'), null=True, blank=True,
#         editable=False, on_delete=models.CASCADE)
# 
#     class Meta:
#         verbose_name = _('Invitation code')
#         verbose_name_plural = _('Invitation codes')
# 
#     class Fields:
#         code = _('Invitation code')
#         expired = {'help_text': _('Visitors won\'t be able to sign up with an expired code.')}
# 
#     @classmethod
#     def add(cls, creator: 'User') -> 'InvitationCode':
#         new_code = cls(creator=creator)
#         new_code.save(force_insert=True)
#         return new_code
# 
#     @classmethod
#     def accept(cls, code: str, acceptor: 'User'):
#         return cls.objects.filter(code=code).update(acceptor=acceptor, expired=True, time_accepted=timezone.now())


# Path: sitegate/tests/test_invitation.py
from sitegate.models import InvitationCode



def test_generate_code(user):
    assert InvitationCode.generate_code()


def test_add(user):

    code = InvitationCode.add(user)