from clients import scopes
from clients.models import Client
from events.models import Event, Calendar
from groups.models import SupportGroup, Membership
from people.models import Person

PASSWORD = 'incredible password'


def load_fake_data():
    clients = {
        'api_front': Client.objects.create_client(
            'api_front',
            password=PASSWORD,
            oauth_enabled=True,
            uris=['http://localhost:8000/authentification/retour/'],
            scopes=['view_profile']
        ),
        'oauth': Client.objects.create_client(
            'oauth',
            password=PASSWORD,
            scopes=['view_profil']
        ),
    }
    clients['oauth'].role.groups.add(Group.objects.get(name='oauth_providers'))

    people = {
        'admin': Person.objects.create_superperson('admin@example.com', PASSWORD),
        'user1': Person.objects.create_person('user1@example.com', PASSWORD),
        'user2': Person.objects.create_person('user2@example.com', PASSWORD),
    }

    # Groups

    groups = {
        'user1_group': SupportGroup.objects.create(name='Groupe géré par user1'),
        'user2_group': SupportGroup.objects.create(name='Groupe géré par user2')
    }
    Membership.objects.create(supportgroup=groups['user1_group'], person=people['user1'], is_manager=True, is_referent=True)
    Membership.objects.create(supportgroup=groups['user2_group'], person=people['user2'], is_manager=True, is_referent=True)
    Membership.objects.create(supportgroup=groups['user1_group'], person=people['user2'])

    return {
        'clients': clients,
        'people': people,
        'groups': groups,
    }



class FakeDataMixin():
    def setUp(self):
        self.data = load_fake_data()
        super().setUp()
@@ -1,20 +1,132 @@
+from datetime import timedelta%0A%0Afrom django.contrib.auth.models import Group%0Afrom django.utils import timezone%0A%0A
 from clients import 
@@ -196,23 +196,16 @@
 ort 
-Event, 
 Calendar
 %0Afro
@@ -200,16 +200,46 @@
 Calendar
+, Event, OrganizerConfig, RSVP
 %0Afrom gr
@@ -1676,16 +1676,1208 @@
 er2'%5D)%0A%0A
+    # Events%0A    calendars = %7B%0A        'evenements_locaux': Calendar.objects.create_calendar('%C3%89v%C3%A8nements locaux', slug='calendar', user_contributed=True),%0A        'national': Calendar.objects.create_calendar('National', slug='national')%0A    %7D%0A%0A    events = %7B%0A        'user1_event1': Event.objects.create(%0A            name='%C3%89v%C3%A9nement cr%C3%A9%C3%A9 par user1',%0A            start_time=timezone.now() + timedelta(days=1),%0A            end_time=timezone.now() + timedelta(days=1, hours=1),%0A            calendar=calendars%5B'evenements_locaux'%5D,%0A        ),%0A        'user1_event2': Event.objects.create(%0A            name='Autre %C3%A9v%C3%A9nement cr%C3%A9%C3%A9 par user1 sans personne dedans',%0A            start_time=timezone.now() + timedelta(days=1),%0A            end_time=timezone.now() + timedelta(days=1, hours=1),%0A            calendar=calendars%5B'evenements_locaux'%5D,%0A        ),%0A    %7D%0A    %5BOrganizerConfig.objects.create(%0A        event=event,%0A        person=people%5B'user1'%5D,%0A        is_creator=True,%0A        as_group=groups%5B'user1_group'%5D%0A    ) for event in %5Bevents%5B'user1_event1'%5D, events%5B'user1_event2'%5D%5D%5D%0A    %5BRSVP.objects.create(person=user, event=events%5B'user1_event1'%5D) for user in %5Bpeople%5B'user1'%5D, people%5B'user2'%5D%5D%5D%0A%0A
     retu
@@ -2961,16 +2961,42 @@
 groups,%0A
+        'events': events,%0A
     %7D%0A%0A%0A

add events to test mixins