from django.test import TestCase

from autostew_back.event_handlers.session_start import HandleSessionStart
from autostew_web_enums.models import SessionState, EventType
from autostew_web_session.factories.event_factories import EventFactory


class TestSessionStart(TestCase):
    def test_can_consume_when_state_changed_to_lobby(self):
        event = EventFactory.create()
        event.type.name = EventType.state_changed
        event.new_session_state = SessionState.lobby

        self.assertTrue(HandleSessionStart.can_consume(None, event))

    def test_can_consume_when_session_gets_created(self):
        event = EventFactory.create()
        event.type.name = EventType.session_created

        self.assertTrue(HandleSessionStart.can_consume(None, event))

    def test_consume(self):
        # nothing to test here. Should be tested by server unit tests
        pass

@@ -1,12 +1,44 @@
+from unittest.mock import Mock%0A%0A
 from django.
@@ -786,32 +786,207 @@
 (None, event))%0A%0A
+    def test_can_not_consume_when_no_session_gets_created(self):%0A        event = EventFactory.create()%0A%0A        self.assertFalse(HandleSessionStart.can_consume(None, event))%0A%0A
     def test_con
@@ -1079,9 +1079,47 @@
     
-pass
+HandleSessionStart.consume(Mock(), Mock())
 %0A

test that consume can fail