random test coverage
This commit is contained in:
parent
5c9b5fa56d
commit
151e4f7f68
4 changed files with 68 additions and 20 deletions
Binary file not shown.
|
@ -43,10 +43,22 @@ def test_addtag_userid_nan(client):
|
|||
response = client.get('/addtag?id=test')
|
||||
assert response.data.decode('utf-8') == "Error: 095"
|
||||
|
||||
def test_addtag(app, client):
|
||||
response_addtag = client.get('/addtag?id=1')
|
||||
#hier muss der userque was hinzugefügt werden!
|
||||
response_tagid = client.get('/api/tag_id?id=12345678')
|
||||
def test_add_tag_direktli(app):
|
||||
with app.app_context():
|
||||
db = get_db()
|
||||
assert db is get_db()
|
||||
c = db.cursor()
|
||||
c.execute("INSERT INTO tags (tagid, userid) VALUES (12345678, 1)")
|
||||
c.execute("INSERT INTO tags (tagid, userid) VALUES (23456789, 1)")
|
||||
db.commit()
|
||||
c.execute("SELECT * FROM tags WHERE tagid = 12345678")
|
||||
data_1 = c.fetchone()
|
||||
c.execute("SELECT * FROM tags WHERE tagid = 23456789")
|
||||
data_2 = c.fetchone()
|
||||
assert data_1[0] == 12345678
|
||||
assert data_1[1] == 1
|
||||
assert data_2[0] == 23456789
|
||||
assert data_2[1] == 1
|
||||
|
||||
#/api
|
||||
def test_api_change(client):
|
||||
|
@ -90,3 +102,41 @@ def test_api_change_right_negativ(app, client):
|
|||
assert data[0] == 1
|
||||
assert data[1] == "test"
|
||||
assert data[2] == 0
|
||||
|
||||
def test_api_tagid(app, client):
|
||||
response = client.get("/api/tag_id")
|
||||
assert json.loads(response.data.decode('utf-8')) == {'error': '054', 'mode': 'error'}
|
||||
|
||||
def test_api_tagid_NaN(app, client):
|
||||
response = client.get("/api/tag_id?id=test")
|
||||
assert json.loads(response.data.decode('utf-8')) == {'error': '054', 'mode': 'error'}
|
||||
|
||||
def test_api_tagid_wrong_id(app, client):
|
||||
response = client.get("/api/tag_id?id=1234")
|
||||
assert json.loads(response.data.decode('utf-8')) == {'error': '054', 'mode': 'error'}
|
||||
|
||||
def test_api_tagid_right_firsttag(app, client):
|
||||
response = client.get("/api/tag_id?id=12345678")
|
||||
with app.app_context():
|
||||
db = get_db()
|
||||
assert db is get_db()
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM users WHERE id = 1")
|
||||
data = c.fetchone()
|
||||
assert data[0] == 1
|
||||
assert data[1] == "test"
|
||||
assert data[2] == -1
|
||||
assert json.loads(response.data.decode('utf-8')) == {'balance': -1, 'mode': 'balance', 'username': 'test'}
|
||||
|
||||
def test_api_tagid_right_firsttag(app, client):
|
||||
response = client.get("/api/tag_id?id=23456789")
|
||||
with app.app_context():
|
||||
db = get_db()
|
||||
assert db is get_db()
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM users WHERE id = 1")
|
||||
data = c.fetchone()
|
||||
assert data[0] == 1
|
||||
assert data[1] == "test"
|
||||
assert data[2] == -2
|
||||
assert json.loads(response.data.decode('utf-8')) == {'balance': -2, 'mode': 'balance', 'username': 'test'}
|
Loading…
Add table
Add a link
Reference in a new issue