Exemplo n.º 1
0
    def test_logout_user(self):

        course_service.create_new_user("test1", "test123")
        user = course_service.login_user("test1", "test123")
        course_service.logout_user()

        self.assertEqual(course_service._user, None)
Exemplo n.º 2
0
    def test_remove_all_courses(self):

        course_service.create_new_user("test1", "test123")
        user = course_service.login_user("test1", "test123")

        name = self.course_test1.name
        credit = self.course_test1.credit
        grade = self.course_test1.grade
        status = self.course_test1.status
        url = self.course_test1.url

        course_service.create_new_course(name, str(credit), grade, status, url)

        name = self.course_test2.name
        credit = self.course_test2.credit
        grade = self.course_test2.grade
        status = self.course_test2.status
        url = self.course_test2.url

        course_service.create_new_course(name, str(credit), grade, status, url)

        # Checks if remove_all_courses worked
        self.assertEqual(course_service.remove_all_courses(), True)

        # Checks that course_test1 is not found anymore for user test1
        self.assertEqual(course_service._c_repo.find_course(
            self.course_test2.name, "test1"), None)
Exemplo n.º 3
0
    def test_create_new_user(self):
        course_service.create_new_user("test3", "test123")

        search_existing_user = user_repository.find_username("test3")
        search_missing_user = user_repository.find_username("test2")

        self.assertEqual(search_existing_user, True)
        self.assertEqual(search_missing_user, None)
Exemplo n.º 4
0
    def test_statistics(self):
        course_service.create_new_user("test2", "test123")
        user = course_service.login_user("test2", "test123")

        name = self.course_test4.name
        credit = self.course_test4.credit
        grade = self.course_test4.grade
        status = self.course_test4.status
        url = self.course_test4.url

        course_service.create_new_course(name, str(credit), grade, status, url)

        self.assertEqual(course_service.statistics(), (1, 6, 5))
Exemplo n.º 5
0
    def test_remove_one_course(self):

        course_service.create_new_user("test1", "test123")
        user = course_service.login_user("test1", "test123")

        name = self.course_test1.name
        credit = self.course_test1.credit
        grade = self.course_test1.grade
        status = self.course_test1.status
        url = self.course_test1.url

        course_service.create_new_course(name, str(credit), grade, status, url)

        self.assertEqual(course_service.remove_one_course(name), True)
    def _create_new_user(self):
        username = self._new_username_entry.get()
        password = self._new_password_entry.get()

        if len(username) > 3 and len(password) > 3:
            try:
                course_service.create_new_user(username, password)
                messagebox.showinfo(
                    "Regisration",
                    f"Successfully registered user: {username}!")
            except ExistingUsernameError:
                messagebox.showinfo("Regisration",
                                    f"Username {username} is already in-use!")
        else:
            messagebox.showinfo(
                "Regisration",
                "Both username and password must be over three characters long!"
            )
Exemplo n.º 7
0
    def test_display_all_courses(self):

        course_service.create_new_user("test1", "test123")
        user = course_service.login_user("test1", "test123")

        name = self.course_test1.name
        credit = self.course_test1.credit
        grade = self.course_test1.grade
        status = self.course_test1.status
        url = self.course_test1.url

        course_service.create_new_course(name, str(credit), grade, status, url)

        name = self.course_test2.name
        credit = self.course_test2.credit
        grade = self.course_test2.grade
        status = self.course_test2.status
        url = self.course_test2.url

        course_service.create_new_course(name, str(credit), grade, status, url)

        course_list = course_service.display_all_courses()

        self.assertEqual(len(course_list), 2)
Exemplo n.º 8
0
    def test_current_user(self):

        course_service.create_new_user("test1", "test123")
        user = course_service.login_user("test1", "test123")
        self.assertEqual(course_service.current_user(), user["username"])
Exemplo n.º 9
0
    def test_login_invalid_password(self):
        course_service.create_new_user("test1", "test123")

        self.assertRaises(
            LoginError, lambda: course_service.login_user("test1", "wrong123"))
Exemplo n.º 10
0
    def test_login_exisiting_user(self):
        course_service.create_new_user("test1", "test123")
        user = course_service.login_user("test1", "test123")

        self.assertEqual(user["username"], "test1")
Exemplo n.º 11
0
    def test_create_exisiting_user(self):
        course_service.create_new_user("test3", "test123")

        self.assertRaises(ExistingUsernameError, lambda: course_service.create_new_user(
            "test3", "test123"))