Exemple #1
0
    def test_error(self):
        os.environ['INT_EMPTY'] = ''
        with self.assertRaises(TypeError):
            parsenvy.int('INT_EMPTY')

        os.environ['INT_STR'] = 'nope'
        with self.assertRaises(TypeError):
            parsenvy.int('INT_STR')
Exemple #2
0
def test_int_positive(monkeypatch):
    monkeypatch.setenv("foo", "13")
    assert parsenvy.int("foo") == 13
Exemple #3
0
def test_int_empty(monkeypatch):
    monkeypatch.setenv("foo", "")
    with pytest.raises(TypeError):
        parsenvy.int("foo")
Exemple #4
0
def test_int_invalid(monkeypatch):
    monkeypatch.setenv("foo", "bar")
    with pytest.raises(TypeError):
        parsenvy.int("foo")
Exemple #5
0
def test_int_negative_zero(monkeypatch):
    monkeypatch.setenv("foo", "-0")
    assert parsenvy.int("foo") == 0
Exemple #6
0
def test_int_negative(monkeypatch):
    monkeypatch.setenv("foo", "-42")
    assert parsenvy.int("foo") == -42
Exemple #7
0
import github3
import parsenvy
from raven.contrib.flask import Sentry
from waitress import serve

parser = configparser.SafeConfigParser()
parser.read('defaults.ini')

VERSION = parser.get('APPLICATION', 'version')

USER_NUMBER = parser.get('USER', 'number')
USER_DAY = parser.get('USER', 'day')
USER_TIME = parser.get('USER', 'time')

DEPLOYMENT = parsenvy.str('DEPLOYMENT', 'DEVELOPMENT')
PORT = parsenvy.int('PORT', 5000)

app = Flask(__name__)
app.secret_key = str(random.getrandbits(128))

sentry = Sentry(app)

if DEPLOYMENT == 'PRODUCTION':
    DB_URL = parsenvy.str('DATABASE_URL')

elif DEPLOYMENT == 'DEVELOPMENT':
    current_dir = os.getcwd()
    full_path = os.path.join(current_dir, 'sm.db')
    DB_URL = 'sqlite:///{0}'.format(full_path)

app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
Exemple #8
0
 def test_default(self):
     self.assertEqual(parsenvy.int('INT_NONE', 3), 3)
Exemple #9
0
 def test_none(self):
     self.assertIsNone(parsenvy.int('INT_NONE'))
Exemple #10
0
 def test_int(self):
     os.environ['INT_2'] = '2'
     self.assertEqual(parsenvy.int('INT_2'), 2)