def test_all_correct(self):
        self.environment.database.create_account("testuser", "1234",
                                                 "supervisor")
        login = Login(self.environment)
        response = login.action(["login", "testuser", "1234"])

        self.assertEqual(response, "Logged in.")
        self.assertIsNotNone(self.environment.user)
    def test_wrong_both(self):
        self.environment.database.create_account("testuser", "1234",
                                                 "supervisor")
        login = Login(self.environment)
        response = login.action(["login", "testuse", "123"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)
    def test_already_logged_in(self):
        self.environment.user = User("someone_else", "supervisor")

        self.environment.database.create_account("testuser", "1234",
                                                 "supervisor")
        login = Login(self.environment)
        response = login.action(["login", "testuser", "1234"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNotNone(self.environment.user)
Beispiel #4
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        core = Core()
        try:
            with open("sign.json", "r", encoding="utf-8") as f:
                data = json.load(f)
        except FileNotFoundError:
            data = {"login": None, "password": None}

        pos = core.login(data.get("login"), data.get("password"))

        layout = QtWidgets.QVBoxLayout()
        login = Login(pos)
        layout.addWidget(login)

        login_button = LoginProcess(core, login)
        layout.addWidget(login_button)

        link = Link(self)
        layout.addWidget(link)

        tables_layout = QtWidgets.QHBoxLayout()

        schedule = Schedule()
        folders = Folders()

        tables_layout.addWidget(schedule)
        tables_layout.addWidget(folders)

        layout.addLayout(tables_layout)

        buttons_layout = QtWidgets.QHBoxLayout()

        progress_update = Progress()
        progress_download = Progress()

        buttons_layout.addWidget(
            SaveButton(schedule, folders, link, login, login_button.checkbox))
        buttons_layout.addWidget(
            ParseScheduleButton(core, schedule, folders, link,
                                progress_update))

        layout.addLayout(buttons_layout)

        layout.addWidget(DownloadButton(core, link, progress_download))

        layout.addWidget(progress_update)
        layout.addWidget(progress_download)

        self.setLayout(layout)
        self.show()
    def test_too_many_args(self):
        login = Login(self.environment)
        response = login.action(["login", "testuser", "1234", "foo"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)
    def test_not_enough_args(self):
        login = Login(self.environment)
        response = login.action(["login", "testuser"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)