Пример #1
0
    def test_get_one_task(self):
        config = copy.copy(CONFIG)
        config.append(('search_query', 'test'))
        config.append(('economic_field', 'customfield_economic'))
        config.append(('default_activity_id', '100'))

        url_re = re.compile(r'http://jira\.example\.com/search\?jql(.)+')
        responses.add(
            responses.GET,
            url_re,
            body=
            '{"startAt": 0,"maxResults": 50,"total": 1,"issues": [{"key": "TEST-1","fields": {"summary": "Task summary","customfield_economic": "200 project X"}}]}',
            status=200,
            content_type='application/json')
        responses.add(
            responses.GET,
            'http://jira.example.com/issue/TEST-1/worklog',
            body='{"startAt":0,"maxResults":50,"total":1,"worklogs":[]}',
            status=200,
            content_type='application/json')
        jira = Jira(config)
        task = next(jira.get_tasks())
        assert '100' == task['activity_id']
        assert datetime.datetime.now().isoformat()[:10] == task['date']
        assert 200 == task['project_id']
        assert 'TEST-1 Task summary' == task['task_description']
        assert '0,0' == task['time_spent']
Пример #2
0
def add_jira_entries(config, date, dry_run, economic):
    """
    Add JIRA tasks as time entries to E-conomic

    :param config:
    :param date:
    :param dry_run:
    :param economic:
    :return:
    """
    if date is not None:
        jira = Jira(config.items('Jira'))
        for task in jira.get_tasks():
            if task:
                economic.add_time_entry(task, dry_run)
Пример #3
0
    def test_get_task_without_economic_id(self):
        config = copy.copy(CONFIG)
        config.append(('search_query', 'test'))
        config.append(('economic_field', 'customfield_economic'))
        config.append(('default_activity_id', '100'))

        url_re = re.compile(r'http://jira\.example\.com/search\?jql(.)+')
        responses.add(responses.GET, url_re,
                      body='{"startAt": 0,"maxResults": 50,"total": 1,"issues": [{"key": "TEST-2","fields": {"summary": "Task summary","customfield": "value"}}]}',
                      status=200,
                      content_type='application/json')
        responses.add(responses.GET, 'http://jira.example.com/issue/TEST-2/worklog',
                      body='{"startAt":0,"maxResults":50,"total":1,"worklogs":[]}', status=200,
                      content_type='application/json')
        jira = Jira(config)
        tasks = jira.get_tasks()
        assert next(tasks, False) is False
Пример #4
0
    def test_get_one_task(self):
        config = copy.copy(CONFIG)
        config.append(('search_query', 'test'))
        config.append(('economic_field', 'customfield_economic'))
        config.append(('default_activity_id', '100'))

        url_re = re.compile(r'http://jira\.example\.com/search\?jql(.)+')
        responses.add(responses.GET, url_re,
                      body='{"startAt": 0,"maxResults": 50,"total": 1,"issues": [{"key": "TEST-1","fields": {"summary": "Task summary","customfield_economic": "200 project X"}}]}',
                      status=200,
                      content_type='application/json')
        responses.add(responses.GET, 'http://jira.example.com/issue/TEST-1/worklog',
                      body='{"startAt":0,"maxResults":50,"total":1,"worklogs":[]}', status=200,
                      content_type='application/json')
        jira = Jira(config)
        task = next(jira.get_tasks())
        assert '100' == task['activity_id']
        assert datetime.datetime.now().isoformat()[:10] == task['date']
        assert 200 == task['project_id']
        assert 'TEST-1 Task summary' == task['task_description']
        assert '0,0' == task['time_spent']
Пример #5
0
    def test_get_tasks_empty_result(self):
        config = copy.copy(CONFIG)
        config.append(('search_query', 'test'))
        config.append(('economic_field', 'customfield_economic'))
        config.append(('default_activity_id', '100'))

        url_re = re.compile(r'http://jira\.example\.com/search\?jql(.)+')
        responses.add(
            responses.GET,
            url_re,
            body='{"startAt": 0,"maxResults": 50,"total": 0,"issues": []}',
            status=200,
            content_type='application/json')
        responses.add(
            responses.GET,
            'http://jira.example.com/issue/TEST-1/worklog',
            body='{"startAt":0,"maxResults":50,"total":1,"worklogs":[]}',
            status=200,
            content_type='application/json')
        jira = Jira(config)
        tasks = jira.get_tasks()
        assert False == next(tasks, False)