def unregister_hook(args): try: github = GithubHandler(load_config()) github.unregister(args.org, args.url) sys.stdout.write('Hook removed successfully\n') except Exception as e: sys.stderr.write('Hook removal failed\n') sys.stderr.write(e.message + '\n') sys.exit(2)
def test_load_config_handles_teams(): expected_teams = { "Channel": { "github-username": { "slack": "slack-username" } } } res = load_config() actual_teams = res.get('TEAMS') eq_(actual_teams, expected_teams)
def test_load_config_handles_happy_slack_emojis(): expected_emojis = [ "exclamation", "heart", "icecream", "joy_cat", "octocat", "rainbow", "smile", "snowflake", "snowman", "sparkles", "squirrel", "tada", ] res = load_config() actual_emojis = res.get('HAPPY_SLACK_EMOJIS') ok_(len(actual_emojis) > 0) eq_(actual_emojis, expected_emojis)
import sys import logging import pkg_resources from flask import Flask, request, Response from pullsbury.config import load_config from pullsbury.handlers.slack_handler import SlackHandler from pullsbury.models.event import Event config = load_config() app = Flask("pullsbury") app.config.update(config) app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.INFO) log = logging.getLogger(__name__) version = pkg_resources.get_distribution('pullsbury').version EVENT_PROCESSORS = {'pull_request.opened': [SlackHandler]} @app.route("/") def ping(): return "pullsbury: %s pong\n" % (version, ) @app.route("/notify", methods=["POST"]) def notify(): try: event = Event(request) processor = u"{}.{}".format(event.type, event.action)
def setUp(self): self.config = load_config()
def get_github_handler(self, custom_config=None): config = load_config() if custom_config: config.update(custom_config) return GithubHandler(config)
def test_load_config(): res = load_config() assert res['GITHUB_USER'].endswith, 'Exists and is stringy'
def test_load_config_returns_io_error_if_setting_file_is_not_found(): load_config(settings_file='./unknown.py')