From 09d5804a09f191f5c64ce73dcaf75859bdc89032 Mon Sep 17 00:00:00 2001 From: Sheng Date: Sun, 22 Apr 2018 20:10:11 +0800 Subject: [PATCH] Prepare to write unit tests --- .coveragerc | 13 ++++++++++++ .gitignore | 1 + .travis.yml | 20 ++++++++++++++++++ README.md | 12 +++++++---- requirements.txt | 2 +- tests/__init__.py | 0 webssh/__init__.py | 0 handler.py => webssh/handler.py | 0 main.py => webssh/main.py | 0 policy.py => webssh/policy.py | 0 {preview => webssh/preview}/login.png | Bin {preview => webssh/preview}/terminal.png | Bin settings.py => webssh/settings.py | 0 .../static}/css/bootstrap.min.css | 0 .../static}/css/fullscreen.min.css | 0 {static => webssh/static}/css/xterm.min.css | 0 {static => webssh/static}/img/favicon.png | Bin {static => webssh/static}/js/bootstrap.min.js | 0 .../static}/js/fullscreen.min.js | 0 {static => webssh/static}/js/jquery.min.js | 0 {static => webssh/static}/js/main.js | 0 {static => webssh/static}/js/popper.min.js | 0 {static => webssh/static}/js/xterm.min.js | 0 {templates => webssh/templates}/index.html | 0 worker.py => webssh/worker.py | 0 25 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 .coveragerc create mode 100644 .travis.yml create mode 100644 tests/__init__.py create mode 100644 webssh/__init__.py rename handler.py => webssh/handler.py (100%) rename main.py => webssh/main.py (100%) rename policy.py => webssh/policy.py (100%) rename {preview => webssh/preview}/login.png (100%) rename {preview => webssh/preview}/terminal.png (100%) rename settings.py => webssh/settings.py (100%) rename {static => webssh/static}/css/bootstrap.min.css (100%) rename {static => webssh/static}/css/fullscreen.min.css (100%) rename {static => webssh/static}/css/xterm.min.css (100%) rename {static => webssh/static}/img/favicon.png (100%) rename {static => webssh/static}/js/bootstrap.min.js (100%) rename {static => webssh/static}/js/fullscreen.min.js (100%) rename {static => webssh/static}/js/jquery.min.js (100%) rename {static => webssh/static}/js/main.js (100%) rename {static => webssh/static}/js/popper.min.js (100%) rename {static => webssh/static}/js/xterm.min.js (100%) rename {templates => webssh/templates}/index.html (100%) rename worker.py => webssh/worker.py (100%) diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..8b32fc7 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = true +source = webssh + +[report] +exclude_lines = + if self.debug: + pragma: no cover + raise NotImplementedError + if __name__ == .__main__.: +ignore_errors = True +omit = + tests/* diff --git a/.gitignore b/.gitignore index df9be38..661e920 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ htmlcov/ .tox/ .coverage .cache +.pytest_cache/ nosetests.xml coverage.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9f0576d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +dist: trusty +sudo: false + +language: python +python: + - "2.7" + - "3.4" + - "3.5" + - "3.6" + +install: + - pip install -r requirements.txt + - pip install pytest pytest-cov codecov flake8 + +script: + - pytest --cov=webssh + - flake8 --exclude='.git' + +after_success: + - codecov diff --git a/README.md b/README.md index fc685ab..996f778 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ ## WebSSH -A simple web application to be used as an ssh client to connect to your ssh servers. It is written in Python, base on Tornado and Paramiko. +[![Build Status](https://travis-ci.org/huashengdun/webssh.svg?branch=master)](https://travis-ci.org/huashengdun/webssh) +[![codecov](https://codecov.io/gh/huashengdun/webssh/branch/master/graph/badge.svg)](https://codecov.io/gh/huashengdun/webssh) +![license](https://img.shields.io/github/license/mashape/apistatus.svg) + +A simple web application to be used as an ssh client to connect to your ssh servers. It is written in Python, base on tornado and paramiko. ### Preview ![Login](https://github.com/huashengdun/webssh/raw/master/preview/login.png) @@ -18,7 +22,7 @@ A simple web application to be used as an ssh client to connect to your ssh serv git clone https://github.com/huashengdun/webssh.git cd webssh pip install -r requirements.txt -python main.py +python webssh/main.py ``` ### Options @@ -41,7 +45,7 @@ python main.py --help ### Nginx config example for running this app behind an nginx server ``` -location / { +location / { proxy_pass http://127.0.0.1:8888; proxy_http_version 1.1; proxy_read_timeout 300; @@ -50,7 +54,7 @@ location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; -} +} ``` ### Tips diff --git a/requirements.txt b/requirements.txt index 8203145..f31b625 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ paramiko==2.4.1 -tornado==5.0.1 +tornado==5.0.2 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/webssh/__init__.py b/webssh/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/handler.py b/webssh/handler.py similarity index 100% rename from handler.py rename to webssh/handler.py diff --git a/main.py b/webssh/main.py similarity index 100% rename from main.py rename to webssh/main.py diff --git a/policy.py b/webssh/policy.py similarity index 100% rename from policy.py rename to webssh/policy.py diff --git a/preview/login.png b/webssh/preview/login.png similarity index 100% rename from preview/login.png rename to webssh/preview/login.png diff --git a/preview/terminal.png b/webssh/preview/terminal.png similarity index 100% rename from preview/terminal.png rename to webssh/preview/terminal.png diff --git a/settings.py b/webssh/settings.py similarity index 100% rename from settings.py rename to webssh/settings.py diff --git a/static/css/bootstrap.min.css b/webssh/static/css/bootstrap.min.css similarity index 100% rename from static/css/bootstrap.min.css rename to webssh/static/css/bootstrap.min.css diff --git a/static/css/fullscreen.min.css b/webssh/static/css/fullscreen.min.css similarity index 100% rename from static/css/fullscreen.min.css rename to webssh/static/css/fullscreen.min.css diff --git a/static/css/xterm.min.css b/webssh/static/css/xterm.min.css similarity index 100% rename from static/css/xterm.min.css rename to webssh/static/css/xterm.min.css diff --git a/static/img/favicon.png b/webssh/static/img/favicon.png similarity index 100% rename from static/img/favicon.png rename to webssh/static/img/favicon.png diff --git a/static/js/bootstrap.min.js b/webssh/static/js/bootstrap.min.js similarity index 100% rename from static/js/bootstrap.min.js rename to webssh/static/js/bootstrap.min.js diff --git a/static/js/fullscreen.min.js b/webssh/static/js/fullscreen.min.js similarity index 100% rename from static/js/fullscreen.min.js rename to webssh/static/js/fullscreen.min.js diff --git a/static/js/jquery.min.js b/webssh/static/js/jquery.min.js similarity index 100% rename from static/js/jquery.min.js rename to webssh/static/js/jquery.min.js diff --git a/static/js/main.js b/webssh/static/js/main.js similarity index 100% rename from static/js/main.js rename to webssh/static/js/main.js diff --git a/static/js/popper.min.js b/webssh/static/js/popper.min.js similarity index 100% rename from static/js/popper.min.js rename to webssh/static/js/popper.min.js diff --git a/static/js/xterm.min.js b/webssh/static/js/xterm.min.js similarity index 100% rename from static/js/xterm.min.js rename to webssh/static/js/xterm.min.js diff --git a/templates/index.html b/webssh/templates/index.html similarity index 100% rename from templates/index.html rename to webssh/templates/index.html diff --git a/worker.py b/webssh/worker.py similarity index 100% rename from worker.py rename to webssh/worker.py