Пример #1
0
 def setUp(self):
     logger = logging.getLogger("JiraBot")
     stream_handler = logging.StreamHandler()
     stream_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s'))
     logger.setLevel("DEBUG")
     logger.addHandler(stream_handler)
     self.jira = Jira("https://comparethemarket.atlassian.net", logger=logger).with_project("BIB")#.with_label("BRO")
Пример #2
0
 def order_by_rank(self):
     jira = Jira("").order_by("Rank")
     self.assertEqual('order by rank', jira.jql)
Пример #3
0
 def test_created_since_8_days_ago(self):
     jira = Jira("").created_in_last_n_days(8)
     self.assertEqual('created >= -8d', jira.jql)
Пример #4
0
 def test_created_since_1_day_ago(self):
     jira = Jira("").created_in_last_n_days(1)
     self.assertEqual('created >= -1d', jira.jql)
Пример #5
0
 def test_query_by_sub_team(self):
     jira = Jira("").with_sub_team("Teamsters")
     self.assertEqual('sub-team = "Teamsters"', jira.jql)
Пример #6
0
    formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
    file_handler = logging.handlers.RotatingFileHandler(
        "/var/log/confluencebot/confluencebot.log",
        maxBytes=10485760,
        backupCount=10)
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    stream_handler = logging.StreamHandler()
    stream_handler.setFormatter(formatter)
    logger.setLevel("INFO")
    logger.addHandler(stream_handler)

    jira_server = args.confluence.strip("/").replace("http://", "")
    confluence_base_url = args.confluence.strip("/") + "/wiki/rest/api/content"

    jira = Jira(jira_server, username=args.user, jql=args.jql, logger=logger)
    confluence = Confluence(base_url=confluence_base_url, username=args.user)

    # Lest we forget...
    # content = confluence.get_page_body(args.pageid)
    # content = content.replace("thingies", "thingies thingies")
    # confluence.update_page(args.pageid, content)
    # print confluence.get_page_body(args.pageid)

    if args.start:
        start = pytz.utc.localize(parser.parse(args.start))
    else:
        start = pytz.utc.localize(datetime.utcnow()) - timedelta(days=7)

    if args.end:
        end = pytz.utc.localize(parser.parse(args.end))
Пример #7
0
 def test_created_between(self):
     jira = Jira("").created_between(datetime(2017, 1, 1),
                                     datetime(2017, 1, 3))
     self.assertEqual('created >= "2017/01/01" and created < "2017/01/03"',
                      jira.jql)
Пример #8
0
 def test_resolved_last_week(self):
     jira = Jira("").resolved_last_week()
     self.assertEqual(
         'resolutionDate >= startOfWeek(-1w) and resolutionDate < endOfWeek(-1w)',
         jira.jql)
Пример #9
0
 def test_not_assigned(self):
     jira = Jira("").not_assigned()
     self.assertEqual('assignee is empty', jira.jql)
Пример #10
0
 def test_project_and_label(self):
     jira = Jira("").with_project("PRJ").with_label("LBL")
     self.assertEqual('project = "PRJ" and labels in ("LBL")', jira.jql)
Пример #11
0
 def test_label_filter(self):
     jira = Jira("").with_label("LAB1")
     self.assertEqual('labels in ("LAB1")', jira.jql)
Пример #12
0
 def test_query_by_ids(self):
     jira = Jira("").with_these_ids(["XXX-470", "YYY-111"])
     self.assertEqual('id in ("XXX-470", "YYY-111")', jira.jql)
Пример #13
0
 def test_query_by_id(self):
     jira = Jira("").with_id("XXX-470")
     self.assertEqual('id = "XXX-470"', jira.jql)
Пример #14
0
 def test_project_filter(self):
     jira = Jira("").with_project("TEST")
     self.assertEqual('project = "TEST"', jira.jql)
Пример #15
0
 def test_resolved_since_2_days_ago(self):
     jira = Jira("").resolved_n_days_ago(2)
     self.assertEqual(
         'resolutionDate >= startOfDay(-2d) and resolutionDate < endOfDay(-2d)',
         jira.jql)
Пример #16
0
 def test_resolved_this_week(self):
     jira = Jira("").resolved_this_week()
     self.assertEqual('resolutionDate >= startOfWeek()', jira.jql)
Пример #17
0
 def test_status_is(self):
     jira = Jira("").status_is("STATE X")
     self.assertEqual('status = "STATE X"', jira.jql)
Пример #18
0
 def test_in_progress_for_7_days(self):
     jira = Jira("").in_progress_for_n_days(7)
     self.assertEqual('status changed to "In Progress" before -7d',
                      jira.jql)
Пример #19
0
 def test_status_was(self):
     jira = Jira("").status_was("STATE X", datetime(2017, 1, 11))
     self.assertEqual('status was "STATE X" on "2017/01/11"', jira.jql)
Пример #20
0
 def test_resolved_between(self):
     jira = Jira("").resolved_between(datetime(2017, 2, 2),
                                      datetime(2017, 2, 9))
     self.assertEqual(
         'resolutionDate >= "2017/02/02" and resolutionDate < "2017/02/09"',
         jira.jql)
Пример #21
0
 def test_status_is_not(self):
     jira = Jira("").status_is_not(["STATE1", "STATE2"])
     self.assertEqual('status not in ("STATE1", "STATE2")', jira.jql)
Пример #22
0
 def test_longer_join(self):
     jira = Jira("").status_is_not(["S1", "S2"
                                    ]).not_assigned().with_label("MYLABEL")
     self.assertEqual(
         'status not in ("S1", "S2") and assignee is empty and labels in ("MYLABEL")',
         jira.jql)
Пример #23
0
                        default="INFO")

    args = parser.parse_args()

    logger = logging.getLogger("JiraBot")
    formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
    file_handler = logging.handlers.RotatingFileHandler(
        "/var/log/jirabot/jirabot.log", maxBytes=10485760, backupCount=10)
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    stream_handler = logging.StreamHandler()
    stream_handler.setFormatter(formatter)
    logger.setLevel(args.log_level)
    logger.addHandler(stream_handler)

    jira = Jira(args.jira, args.user, logger=logger)
    slack = Slack(args.slack_key, logger=logger)

    bot = JiraBot(jira=jira,
                  slack=slack,
                  project=args.project,
                  label=args.label,
                  fix_version=args.fix_version,
                  channel=args.channel,
                  logger=logger,
                  wip_limit=args.wip_limit)

    slack.send(args.channel, ":tada: I just restarted. Hello!")
    count = 0
    while True:
        try: