Esempio n. 1
0
def test_usermanager_reputation():
    """
    Setups tests the user managers reputation function
    """
    test_user = {
        "username": "******",
        "jobs": 1,
        "reputation": int(Config.get("reputation", "TrustedLevel")) + 1,
    }
    DBManager.add_user(test_user["username"], test_user["jobs"], test_user["reputation"])
    rep_level = UserManager.get_rep_level(test_user["username"])
    assert rep_level == "Very Trusted"
Esempio n. 2
0
def test_dbmanager_oldposts():
    """
    Tests the oldpost section of the database
    """
    test_id = "0"

    if DBManager.is_oldpost(test_id):
        DBManager.del_oldpost(test_id)

    DBManager.add_oldpost(test_id)
    assert DBManager.is_oldpost(test_id)

    DBManager.del_oldpost(test_id)
    assert DBManager.is_oldpost(test_id) is False
Esempio n. 3
0
def setup_module():
    """
    Setups the tables if not already
    """
    if not os.path.exists("offerbot.db"):
        DBManager.init_tables()
Esempio n. 4
0
def test_dbmanager_init_tables():
    """
    Tests the creation of the sqlite tables
    """
    DBManager.init_tables()
    assert os.path.exists('offerbot.db')
Esempio n. 5
0
def test_dbmanager_users():
    """
    Tests the user section of the database
    """
    test_user = {
        'username': '******',
        'jobs': 0,
        'reputation': 10
    }

    if DBManager.is_user(test_user['username']):
        DBManager.del_user(test_user['username'])

    DBManager.add_user(test_user['username'], test_user['jobs'], test_user['reputation'])
    assert DBManager.is_user(test_user['username'])

    get_test_user = DBManager.get_user(test_user['username'])
    assert get_test_user['reputation'] == test_user['reputation']

    DBManager.update_user(test_user['username'], 20, test_user['reputation'])
    get_test_user = DBManager.get_user(test_user['username'])
    assert get_test_user['jobs'] == 20

    DBManager.del_user(test_user['username'])
    assert DBManager.is_user(test_user['username']) is False