Skip to content

Commit

Permalink
tweak tests and code for 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
drivet committed Sep 20, 2015
1 parent 344adb5 commit 2ae470c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 1 addition & 8 deletions pylint_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,11 @@ def ensure_path(path):
os.makedirs(path)


def create_app(config=None):
def create_app():
app = Flask(__name__)
app.config.from_object(__name__)
if config:
app.config.from_object(config)
app.config['PROPAGATE_EXCEPTIONS'] = True
app.logger.setLevel(app.config['LOG_LEVEL'])
app.register_blueprint(mainbp)
return app


if __name__ == '__main__':
app = create_app()
app.debug = True
app.run(port=4568)
13 changes: 13 additions & 0 deletions test_pylint_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ def test_rating_less_than_7_generates_red_badge(self):
response = self.client.post('/reports', data=get_post_data('6'))
self.assertTrue('b94947' in load_file('/tmp/pylint-server/drivet/yawt/rating.svg'))

def test_rating_less_than_0_generates_grey_badge(self):
response = self.client.post('/reports', data=get_post_data('-1'))
self.assertTrue('9d9d9d' in load_file('/tmp/pylint-server/drivet/yawt/rating.svg'))

def test_rating_greater_than_10_generates_grey_badge(self):
response = self.client.post('/reports', data=get_post_data('11'))
self.assertTrue('9d9d9d' in load_file('/tmp/pylint-server/drivet/yawt/rating.svg'))

def test_missing_slug_raises_error(self):
pylint_server.TravisPy = FakeTravisApi(FakeJob(jobid=123, repoid=456),
FakeRepo(slug=''))
self.assertRaises(ValueError, self.client.post, '/reports', data=get_post_data('9.5'))

def tearDown(self):
if os.path.exists('/tmp/pylint-server'):
shutil.rmtree('/tmp/pylint-server')
Expand Down

0 comments on commit 2ae470c

Please sign in to comment.