Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
fix #527
Browse files Browse the repository at this point in the history
  • Loading branch information
40huo committed Sep 5, 2017
1 parent 1fa751d commit b0c8b5a
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions tests/test_apiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_add_job():
url = "http://127.0.0.1:5000/api/add"
post_data = {
"key": "your_secret_key",
"target": ["tests/vulnerabilities"],
"target": [os.path.join(project_directory, 'tests/vulnerabilities')]
}
headers = {
"Content-Type": "application/json",
Expand Down Expand Up @@ -106,22 +106,11 @@ def test_close_api():
p.join()

# wait for scan process
while True:
cobra_process = os.popen('ps aux | grep python').read()
cobra_process_num = len(cobra_process.strip().split('\n'))
if cobra_process_num <= 3:
# grep python
# sh -c ps aux | grep python
# python pytest
break
time.sleep(1)

# whether port 5000 is closed
s = socket.socket()
s.settimeout(0.5)
try:
assert s.connect_ex(('localhost', 5000)) != 0
finally:
s.close()
while s.connect_ex(('localhost', 5000)) == 0:
time.sleep(1)

# whether port 5000 is closed
assert s.connect_ex(('localhost', 5000)) != 0
assert not os.path.exists(config_path)

0 comments on commit b0c8b5a

Please sign in to comment.