This repository was archived by the owner on Aug 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +55
-5
lines changed
Expand file tree Collapse file tree 7 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 88* .un~
990 /
1010tests /.cache
11+ .coverage
12+ .cache
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ python-rtmbot
22=============
33
44[ ![ Build Status] ( https://travis-ci.org/slackhq/python-rtmbot.png )] ( https://travis-ci.org/slackhq/python-rtmbot )
5+ [ ![ Coverage Status] ( https://coveralls.io/repos/github/slackhq/python-rtmbot/badge.svg?branch=master )] ( https://coveralls.io/github/slackhq/python-rtmbot?branch=master )
56
67A Slack bot written in python that connects via the RTM API.
78
Original file line number Diff line number Diff line change 1+ coveralls == 1.1
2+ ipdb == 0.9.3
3+ ipython == 4.1.2
4+ pdbpp == 0.8.3
15pytest >= 2.8.2
6+ pytest-cov == 2.2.1
27pytest-pythonpath >= 0.3
3- tox >= 1.8.0
8+ testfixtures == 4.9.1
9+ tox >= 1.8.0
Original file line number Diff line number Diff line change 1- from core import *
1+ from . core import *
Original file line number Diff line number Diff line change 1212
1313class RtmBot (object ):
1414 def __init__ (self , config ):
15+ '''
16+ Params:
17+ - config (dict):
18+ - SLACK_TOKEN: your authentication token from Slack
19+ - BASE_PATH (optional: defaults to execution directory) RtmBot will
20+ look in this directory for plugins.
21+ - LOGFILE (optional: defaults to rtmbot.log) The filename for logs, will
22+ be stored inside the BASE_PATH directory
23+ - DEBUG (optional: defaults to False) with debug enabled, RtmBot will
24+ break on errors
25+ '''
1526 # set the config object
1627 self .config = config
1728
@@ -30,7 +41,7 @@ def __init__(self, config):
3041 logging .basicConfig (filename = log_file ,
3142 level = logging .INFO ,
3243 format = '%(asctime)s %(message)s' )
33- logging .info (self .directory )
44+ logging .info ('Initialized in: {}' . format ( self .directory ) )
3445 self .debug = self .config .get ('DEBUG' , False )
3546
3647 # initialize stateful fields
Original file line number Diff line number Diff line change 1+ from testfixtures import LogCapture
2+ from rtmbot .core import RtmBot
3+
4+
5+ def test_init ():
6+ with LogCapture () as l :
7+ rtmbot = RtmBot ({
8+ 'SLACK_TOKEN' : 'test-12345' ,
9+ 'BASE_PATH' : '/tmp/' ,
10+ 'LOGFILE' : '/tmp/rtmbot.log' ,
11+ 'DEBUG' : True
12+ })
13+
14+ assert rtmbot .token == 'test-12345'
15+ assert rtmbot .directory == '/tmp/'
16+ assert rtmbot .debug == True
17+
18+ l .check (
19+ ('root' , 'INFO' , 'Initialized in: /tmp/' )
20+ )
Original file line number Diff line number Diff line change @@ -9,9 +9,14 @@ max-line-length= 100
99exclude = tests/*
1010
1111[testenv]
12- commands =py.test {posargs:tests}
12+ passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
13+ commands =
14+ py.test --cov-report = --cov =rtmbot {posargs:tests}
15+ coveralls
16+
1317deps =
1418 -r{toxinidir}/requirements-dev.txt
19+ -r{toxinidir}/requirements.txt
1520basepython =
1621 py27: python2.7
1722 py34: python3.4
@@ -20,4 +25,9 @@ basepython =
2025[testenv:flake8]
2126basepython =python
2227deps =flake8
23- commands =flake8 {toxinidir}/rtmbot.py {toxinidir}/rtmbot/core.py {toxinidir}/setup.py {toxinidir}/doc/example-plugins
28+ commands =
29+ flake8 \
30+ {toxinidir}/rtmbot.py \
31+ {toxinidir}/rtmbot/core.py \
32+ {toxinidir}/setup.py \
33+ {toxinidir}/doc/example-plugins
You can’t perform that action at this time.
0 commit comments