Esempio 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)
Esempio 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)
Esempio n. 3
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))
Esempio n. 4
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)
Esempio n. 5
0
    def _login_user(self):
        username = self._username_entry.get()
        password = self._password_entry.get()

        if len(username) > 0 and len(password) > 0:
            try:
                if course_service.login_user(username, password):
                    self._show_course_view()
            except LoginError:
                messagebox.showinfo(
                    "Login", "Login failed! Invalid username and/or password.")

        else:
            messagebox.showinfo(
                "Login", "Enter both the username and password to login!")
Esempio n. 6
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)
Esempio n. 7
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"])
Esempio n. 8
0
    def test_login_invalid_password(self):
        course_service.create_new_user("test1", "test123")

        self.assertRaises(
            LoginError, lambda: course_service.login_user("test1", "wrong123"))
Esempio n. 9
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")