Example #1
0
    def test_find_by_username(self):
        user_repository.create(self.user1)
        user_repository.create(self.user2)
        user_repository.create(self.user3)
        users = user_repository.find_by_username("kaija")

        self.assertEqual(len(users), 1)
        self.assertEqual(users[0][0], self.user3.get_username())
Example #2
0
    def handle_login(self, username, password):
        user = user_repository.find_by_username(username)

        if not user or user.password != password:
            return False

        self.user = user

        self.hide_login_view()
        self.show_todos_view()

        return True
    def read(self):
        todos = []

        self.ensure_file_exists()

        with open(self.file_path) as file:
            for row in file:
                row = row.replace('\n', '')
                parts = row.split(';')

                todo_id = parts[0]
                content = parts[1]
                done = parts[2] == '1'
                username = parts[3]

                user = user_repository.find_by_username(
                    username) if username else None

                todos.append(Todo(content, done, user, todo_id))

        return todos
Example #4
0
    def test_find_by_username(self):
        user_repository.create(self.user_kalle)

        user = user_repository.find_by_username(self.user_kalle.username)

        self.assertEqual(user.username, self.user_kalle.username)