Beispiel #1
0
    def add_test(url: str = None,
                 headers: dict = None,
                 project_id: str = None,
                 story_key: str = None,
                 test_description: str = None,
                 test_name: str = None,
                 test_type: str = None):
        """
        Create a Jira "test" entry related to a project and story
        TODO work on the customfield as it may vary with the jira setting
        :param url: the jira server url without endpoint
        :param headers: the request headers
        :param project_id: the project id not the project key
        :param story_key: the story key the test is related to
        :param test_description: the test description
        :param test_name: the test name
        :param test_type: the test type (Manual, Cucumber, Generic)
        :return: the create link response and the test key
        """
        data = {
            "fields": {
                "project": {
                    "id": str(project_id)
                },
                "summary": test_name,
                "description": "",
                "issuetype": {
                    "id":
                    str(
                        JiraIssue.get_issue_identifier(
                            url=url,
                            headers=headers,
                            issue_type=JiraTests.TEST))
                },
                "customfield_10202": {
                    "value": "Cucumber"
                },
                "customfield_10203": {
                    "value": str(test_type)
                },
                "customfield_10204": test_description
            }
        }

        response = JiraIssue.create_issue(url=url,
                                          headers=headers,
                                          issue_data=data)
        key = response.json()["key"]

        response = JiraIssue.create_link(url=url,
                                         headers=headers,
                                         from_key=key,
                                         to_key=story_key,
                                         link_type="Tests")
        return response, key
Beispiel #2
0
    def get_issue_identifier(self, issue_type: str = None):
        """
        Retrieve the issue id of a specific issue type.

        :param issue_type: the issue name
        :return: a string as a Jira id
        """
        assert isinstance(issue_type, str), "issue_type must be a string"

        return JiraIssue.get_issue_identifier(url=self.url,
                                              headers=self.header(),
                                              issue_type=issue_type)
 def create_story(url=None,
                  headers=None,
                  project_id=None,
                  title=None,
                  description=None,
                  epic_key=None,
                  actor=None,
                  action=None,
                  benefit=None):
     """
     Request the creation of a story
     :param project_id:
     :param headers:
     :param url:
     :param action:
     :param benefit:
     :param actor:
     :param epic_key:
     :param title:
     :param description:
     :return: request response
     """
     data = {
         "fields": {
             "project": {
                 "id": str(project_id)
             },
             "summary": title,
             "issuetype": {
                 "id":
                 str(
                     JiraIssue.get_issue_identifier(
                         url=url,
                         headers=headers,
                         issue_type=JiraStories.STORY))
             },
             "description": description,
             "customfield_10002": epic_key,
             JiraStories.ROLE_JIRA_KEY: actor,
             JiraStories.ACTION_JIRA_KEY: action,
             JiraStories.BENEFIT_JIRA_KEY: benefit
         }
     }
     return JiraIssue.create_issue(url=url,
                                   headers=headers,
                                   issue_data=data)
Beispiel #4
0
 def add_epic(url=None, headers=None, project_id=None, epic_name=None, epic_summary=None):
     data = {"fields": {"project": {"id": str(project_id)},
                        "summary": epic_summary,
                        "issuetype": {"id": str(JiraIssue.get_issue_identifier(issue_type=JiraEpics.EPIC))},  # noqa
                        "customfield_10004": epic_name}}
     return JiraIssue.create_issue(url=url, headers=headers, issue_data=data)