-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.py
More file actions
35 lines (23 loc) · 744 Bytes
/
test_api.py
File metadata and controls
35 lines (23 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
import os
import sys
import requests
import hashlib
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
def get_text_md5_hash(text):
enc = hashlib.md5()
enc.update(text.encode('utf-8'))
enc_text = enc.hexdigest()
return enc_text
def test_req_index():
with requests.Session() as s:
req = s.get('http://localhost:65432/')
assert req.status_code == 200
assert req.headers == {'Accept-Charset': 'utf-8'}
req = s.head('http://localhost:65432/')
assert req.status_code == 200
assert req.headers == {'Accept-Charset': 'utf-8'}
def test_req_static():
with requests.Session() as s:
req = s.get('http://localhost:65432/static/css/main.css')
assert req.status_code == 200