Пример #1
0
def printJobMenuNotifications(dbCursor, dbConnection):
    print("\nNotifications:")
    new_jobs_notifications = db.getNotificationsForUserByType(
        dbCursor, "new_job", settings.signedInUname)
    jobs_deleted_notifications = db.getNotificationsForUserByType(
        dbCursor, "job_deleted", settings.signedInUname)
    if len(new_jobs_notifications) == 0 and len(
            jobs_deleted_notifications) == 0:
        print("No current notifications.")

    # notifications for new jobs posted
    if len(new_jobs_notifications) > 0:
        for n in new_jobs_notifications:
            print(f"A new job '{n[2]}' has been posted.")
            db.deleteNotification(dbCursor, n[1], n[2], n[3])
            dbConnection.commit()

    # notifications for applied-for jobs getting deleted
    if len(jobs_deleted_notifications) > 0:
        for n in jobs_deleted_notifications:
            print(f"A job that you applied for has been deleted - '{n[2]}'.")
            db.deleteNotification(dbCursor, n[1], n[2], n[3])
            dbConnection.commit()

    appliedJobs = len(db.getAppliedJobs(dbCursor, settings.signedInUname))
    if appliedJobs == 1:
        print("\nYou have currently applied for 1 job!")
    else:
        print(f"\nYou have currently applied for {appliedJobs} jobs!")
Пример #2
0
def testApplyForJob(monkeypatch):
    connection = sqlite3.connect("incollege_test.db")
    cursor = connection.cursor()
    cursor.execute("DROP TABLE IF EXISTS Users") #delete tables to make sure no conflicts when running test multiple times
    cursor.execute("DROP TABLE IF EXISTS user_job_applications")
    db.initTables(cursor)
    db.insertUser(cursor, "username1", "password", "first1", "last1", 0, "01/01/2020")
    db.insertUser(cursor, "username2", "password", "first2", "last2", 0, "01/01/2020")
    db.insertJob(cursor, "title1", "desc1", "emp1", "loc1", "sal1", "first1 last1")
    selectedJob = db.getAllJobs(cursor)[0]
    settings.signedInUname = "username2"
    monkeypatch.setattr("sys.stdin", StringIO("1\n01/01/1234\n01/02/1234\ncredentials\n"))
    jobs.applyForJob(cursor, connection, selectedJob)
    assert len(db.getAppliedJobs(cursor, "username2")) == 1
Пример #3
0
def testDeleteJobPost(monkeypatch):
    connection = sqlite3.connect("incollege_test.db")
    cursor = connection.cursor()
    cursor.execute("DROP TABLE IF EXISTS Users") #delete tables to make sure no conflicts when running test multiple times
    db.initTables(cursor)
    db.insertUser(cursor, "username1", "password", "first1", "last1", 0, "2020-01-01 12:30:00")
    db.insertUser(cursor, "username2", "password", "first2", "last2", 0, "2020-01-01 12:30:00")
    settings.signedInUname = "username1"
    db.insertJob(cursor, "title1", "desc1", "emp1", "loc1", "sal1", "first1 last1")
    db.insertJob(cursor, "title2", "desc2", "emp2", "loc2", "sal2", "first1 last1")
    assert db.getNumJobs(cursor) == 2
    db.insertUserJobApplication(cursor, "username2", "title1", "01/01/1243", "01/02/1243", "credentials", "2020-01-01 12:30:00")
    monkeypatch.setattr("sys.stdin", StringIO("1\nN\n"))
    jobs.enterDeleteAJobMenu(cursor, connection)
    assert db.getNumJobs(cursor) == 1
    assert len(db.getAppliedJobs(cursor, "username2")) == 0
Пример #4
0
def printJobsWithFilter(dbCursor, dbConnection, filterOption):
    while True:
        jobs = None
        title = ""
        if filterOption == 0:
            jobs = db.getAllJobs(dbCursor)
            title = "All Jobs:"
        elif filterOption == 1:
            jobs = db.getFavoriteJobsByUser(dbCursor, settings.signedInUname)
            title = "Favorite Jobs:"
        elif filterOption == 2:
            jobs = db.getAppliedJobs(dbCursor, settings.signedInUname)
            title = "Jobs Applied To:"
        elif filterOption == 3:
            jobs = db.getUnappliedJobs(dbCursor, settings.signedInUname)
            title = "Jobs Not Applied To:"

        print()
        if len(jobs) > 0:
            print(title)
            for i in range(len(jobs)):
                if len(db.getUserJobApplicationByTitle(dbCursor, settings.signedInUname, (jobs[i])[1])) > 0:  # if user has applied to this job
                    print(f"{i + 1}. {(jobs[i])[1]} (Applied)")
                else:
                    print(f"{i + 1}. {(jobs[i])[1]}")
        else:
            print("No jobs available under this filter.")
            return

        print("#. Choose one of the above jobs to view details")
        print("Z. Return to Previous Menu")

        while True:
            response = input("Input: ")
            if response.isdigit() and 1 <= int(response) <= len(jobs):
                selectedJob = jobs[int(response) - 1]
                viewJobDetails(dbCursor, dbConnection, selectedJob)
                break
            elif response.upper() == "Z":
                return
            else:
                print(constants.INVALID_INPUT)