Skip to content

Commit c76152a

Browse files
authored
Merge pull request #1 from esecules/esecules-test1
Enabled CI
2 parents 7a30239 + c51274a commit c76152a

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

.travis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
language: python
22
python:
3-
- "2.6"
43
- "2.7"
5-
- "3.2"
6-
- "3.3"
7-
- "3.4"
8-
- "3.5"
9-
- "3.5-dev" # 3.5 development branch
10-
- "nightly" # currently points to 3.6-dev
114
# command to install dependencies
125
install: "pip install -r setup/requirements.txt"
136
# command to run tests
14-
script: "exit 0"
7+
script: "cd test; python -m unittest ServerTest.ServerTest"

test/ServerTest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import unittest
2+
import requests
3+
import subprocess
4+
from time import sleep
5+
class ServerTest(unittest.TestCase):
6+
def test_request(self):
7+
serverProc = subprocess.Popen(['python', '../src/server.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8+
sleep(1)
9+
self.assertEqual(None, serverProc.poll())
10+
test_data = "1234567890asdf"
11+
resp = requests.get("http://localhost:5000?oauth_verifier=%s" % test_data)
12+
assert resp.status_code == 200
13+
with self.assertRaises(requests.ConnectionError):
14+
resp = requests.get("http://localhost:5000?oauth_verifier=%s" % test_data)
15+
16+
polls = 0
17+
while serverProc.poll() is None and polls < 10:
18+
polls += 1
19+
sleep(1)
20+
21+
status = serverProc.poll()
22+
if status is None:
23+
serverProc.kill()
24+
self.fail("Server process is still alive, killing now...")
25+
stdout, _ = serverProc.communicate()
26+
stdout = stdout.strip()
27+
self.assertEqual(0, status, "Server exited with nonzero status: %s stdout: %s" % (status, stdout))
28+
self.assertEqual(test_data, stdout, "server didnt return fake oauth verifier, instead: '%s'" % stdout)

0 commit comments

Comments
 (0)