Add pre-commit

This commit is contained in:
Christophe Mehay 2017-08-21 00:46:24 +02:00
parent 27dd14ab33
commit f206ea354c
8 changed files with 114 additions and 40 deletions

View file

@ -1,13 +1,13 @@
from onions import Onions
import json
import os
import pytest
import re
from Crypto.PublicKey import RSA
from hashlib import sha1
from base64 import b32encode
from hashlib import sha1
import pytest
from Crypto.PublicKey import RSA
from onions import Onions
def get_key_and_onion():
key = '''
@ -40,6 +40,7 @@ bhJ3M9WzP/EMkAzyW8mVs1moFp3hRcfQlZHl6g1U9D8=
return key.strip(), onion
def get_torrc_template():
return r'''
{% for service_group in services %}
@ -65,6 +66,7 @@ SocksPort 0
# useless line for Jinja bug
'''.strip()
def test_ports(monkeypatch):
env = {
'SERVICE1_PORTS': '80:80',
@ -104,6 +106,7 @@ def test_ports(monkeypatch):
assert check == 10
def test_docker_links(fs, monkeypatch):
env = {
@ -186,6 +189,7 @@ def test_key(monkeypatch):
assert onion.services[0].onion_url == onion_url
def test_key_in_secret(fs, monkeypatch):
env = {
'SERVICE1_SERVICE_NAME': 'group1',
@ -284,6 +288,7 @@ def test_configuration(fs, monkeypatch):
(port.port_from, port.dest) for port in service.ports
) == set([(80, 'unix://unix.socket')])
def test_groups(monkeypatch):
env = {
'SERVICE1_SERVICE_NAME': 'group1',
@ -323,6 +328,7 @@ def test_groups(monkeypatch):
assert re.match(onion_match, group.onion_url)
def test_json(monkeypatch):
env = {
'SERVICE1_SERVICE_NAME': 'group1',
@ -345,6 +351,7 @@ def test_json(monkeypatch):
assert len(jsn['group1']) == 3
assert len(jsn['group2']) == 1
def test_output(monkeypatch):
env = {
'SERVICE1_SERVICE_NAME': 'group1',
@ -363,6 +370,7 @@ def test_output(monkeypatch):
for item in ['group1', 'group2', '.onion', ',']:
assert item in str(onion)
def test_not_valid_share_port(monkeypatch):
env = {
'SERVICE1_SERVICE_NAME': 'group1',
@ -382,6 +390,7 @@ def test_not_valid_share_port(monkeypatch):
onion.check_services()
assert 'Same port for multiple services' in str(excinfo.value)
def test_not_valid_no_services(monkeypatch):
env = {
'SERVICE1_SERVICE_NAME': 'group1',