Example #1
0
    def test_failed_join_session_not_found(self):
        session_code = "083bd39f-1ddc-4f94-b12f-ca9904e2985a"
        second_user = User.objects.get(username="******")
        same_session = SessionUseCase(second_user.username)

        with self.assertRaises(NotFound):
            same_session.join(session_code)
Example #2
0
    def test_create(self):
        user = User.objects.get(username="******")
        session = SessionUseCase(user.username)
        data = session.create()
        print(data)

        self.assertTrue(data is not None)
        self.assertEqual(user.id, data["user"])
Example #3
0
    def test_retrieve(self):
        first_user = User.objects.get(username="******")
        session = SessionUseCase(first_user.username)
        data = session.create()

        result = session.retrieve(data["code"])

        self.assertIn("messages", result)
Example #4
0
    def test_pass_create_message(self):
        message = "message"

        first_user = User.objects.get(username="******")
        session = SessionUseCase(first_user.username)
        data = session.create()

        result = session.create_message(data["code"], {"message": message})

        self.assertEqual(message, result["message"])
Example #5
0
    def test_failed_join(self):
        user = User.objects.get(username="******")
        session = SessionUseCase(user.username)
        data = session.create()

        same_session = SessionUseCase(user.username)
        same_session.join(data["code"])

        with self.assertRaises(Member.DoesNotExist):
            Member.objects.get(user=user, session_id=data["id"])
Example #6
0
    def test_pass_join(self):
        first_user = User.objects.get(username="******")
        second_user = User.objects.get(username="******")
        session = SessionUseCase(first_user.username)
        data = session.create()

        same_session = SessionUseCase(second_user.username)
        same_session.join(data["code"])

        member = Member.objects.get(user=second_user, session_id=data["id"])

        self.assertEqual(second_user.id, member.user.id)
Example #7
0
    def test_false_can_join(self):
        user = User.objects.get(username="******")
        session = SessionUseCase(user.username)
        data = session.create()

        same_session = SessionUseCase(user.username)
        result = same_session.can_join_session(data["code"])

        self.assertEqual(False, result)
Example #8
0
    def test_true_can_join(self):
        first_user = User.objects.get(username="******")
        second_user = User.objects.get(username="******")

        session = SessionUseCase(first_user.username)
        data = session.create()

        same_session = SessionUseCase(second_user.username)
        result = same_session.can_join_session(data["code"])

        self.assertEqual(True, result)
Example #9
0
    def test_failed_is_session_exists(self):
        session_code = "083bd39f-1ddc-4f94-b12f-ca9904e2985a"

        with self.assertRaises(NotFound):
            SessionUseCase.is_session_exists(session_code)
Example #10
0
    def test_pass_is_session_exists(self):
        first_user = User.objects.get(username="******")
        session = Session.objects.create(user=first_user)

        self.assertEqual(True, SessionUseCase.is_session_exists(session.code))