Skip to content

Commit a6c2118

Browse files
test: Add tests for vue integration
Other changes: - Add travis integration
1 parent ccd0866 commit a6c2118

7 files changed

+56
-0
lines changed

.travis.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
sudo: required
2+
dist: trusty
3+
language: python
4+
python:
5+
- "3.6"
6+
env:
7+
- CI_TEST=true
8+
- FLASK_APP=wsgi:app
9+
before_install:
10+
- curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
11+
- sudo apt-get install nodejs
12+
install:
13+
- pip install -r requirements.txt
14+
- cd web
15+
- npm install
16+
- npm run build
17+
- cd ..
18+
before_script:
19+
- flask run &
20+
- sleep 3
21+
script:
22+
- pytest tests/

bin/phantomjs-linux

64.8 MB
Binary file not shown.

bin/phantomjs-mac

42.9 MB
Binary file not shown.

bin/phantomjs.exe

17.7 MB
Binary file not shown.

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ psycogreen==1.0.1
99
pytest==4.0.2
1010
pytest-cov==2.6.1
1111
pytest-mock==1.10.1
12+
selenium==3.141.0

tests/conftest.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import os
2+
import platform
3+
14
from gevent import monkey
5+
from selenium import webdriver
26

37
monkey.patch_all(thread=False)
48

@@ -40,3 +44,23 @@ def client(flask_app):
4044
def db(flask_app):
4145
from app.models.database import db as db_instance
4246
yield db_instance
47+
48+
49+
@pytest.fixture(scope='session')
50+
def path():
51+
if platform.system() == 'Linux':
52+
return 'bin/phantomjs-linux'
53+
elif platform.system() == 'Darwin':
54+
return 'bin/phantomjs-mac'
55+
elif platform.system() == 'Windows':
56+
return 'bin/phantomjs.exe'
57+
58+
59+
@pytest.fixture(scope='session')
60+
def driver(path):
61+
if os.getenv('CI_TEST', None):
62+
driver_ = webdriver.PhantomJS()
63+
else:
64+
driver_ = webdriver.PhantomJS(path)
65+
yield driver_
66+
driver_.quit()

tests/test_vue_integration.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import socket
2+
from contextlib import closing
3+
4+
5+
def test_text_is_show(driver):
6+
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
7+
if sock.connect_ex(('localhost', 5000)) == 0:
8+
driver.get('http://localhost:5000/views/sample')
9+
assert 'Welcome to Your Vue.js App' in driver.page_source

0 commit comments

Comments
 (0)