Ejemplo n.º 1
0
 def test_update_project_version(self):
     # given
     name = "version-%s" % rndstr()
     version = self.jira.create_version(name, self.project_b,
                                        "will be deleted soon")
     updated_name = "version-%s" % rndstr()
     # when
     version.update(name=updated_name)
     # then
     self.assertEqual(updated_name, version.name)
     version.delete()
Ejemplo n.º 2
0
    def test_3_update(self):
        try:
            components = self.jira.project_components(self.project_b)
            for component in components:
                if component.name == "To be updated":
                    component.delete()
                    break
        except Exception:
            # We ignore errors as this code intends only to prepare for
            # component creation
            raise

        name = "component-" + rndstr()

        component = self.jira.create_component(
            name,
            self.project_b,
            description="stand by!",
            leadUserName=self.jira.current_user(),
        )
        name = "renamed-" + name
        component.update(name=name,
                         description="It is done.",
                         leadUserName=self.jira.current_user())
        self.assertEqual(component.name, name)
        self.assertEqual(component.description, "It is done.")
        self.assertEqual(component.lead.name, self.jira.current_user())
        component.delete()
Ejemplo n.º 3
0
 def test_project_versions_with_project_obj(self):
     name = "version-%s" % rndstr()
     version = self.jira.create_version(name, self.project_b,
                                        "will be deleted soon")
     project = self.jira.project(self.project_b)
     versions = self.jira.project_versions(project)
     self.assertGreaterEqual(len(versions), 1)
     test = find_by_id(versions, version.id)
     self.assertEqual(test.id, version.id)
     self.assertEqual(test.name, name)
     version.delete()
Ejemplo n.º 4
0
 def test_filter(self):
     jql = "project = %s and component is not empty" % self.project_b
     name = "same filter " + rndstr()
     myfilter = self.jira.create_filter(
         name=name,
         description="just some new test filter",
         jql=jql,
         favourite=False)
     self.assertEqual(myfilter.name, name)
     self.assertEqual(myfilter.owner.name,
                      self.test_manager.user_admin.name)
     myfilter.delete()
Ejemplo n.º 5
0
    def test_project_versions(self):
        name = "version-%s" % rndstr()
        version = self.jira.create_version(name, self.project_b,
                                           "will be deleted soon")
        versions = self.jira.project_versions(self.project_b)
        self.assertGreaterEqual(len(versions), 1)
        test = find_by_id(versions, version.id)
        self.assertEqual(test.id, version.id)
        self.assertEqual(test.name, name)

        i = self.jira.issue(self.test_manager.project_b_issue1)
        i.update(fields={"fixVersions": [{"id": version.id}]})
        version.delete()
Ejemplo n.º 6
0
    def test_favourite_filters(self):
        # filters = self.jira.favourite_filters()
        jql = "project = %s and component is not empty" % self.project_b
        name = "filter-to-fav-" + rndstr()
        myfilter = self.jira.create_filter(
            name=name,
            description="just some new test filter",
            jql=jql,
            favourite=True)
        new_filters = self.jira.favourite_filters()

        assert name in [f.name for f in new_filters]
        myfilter.delete()
Ejemplo n.º 7
0
 def test_2_create_component(self):
     proj = self.jira.project(self.project_b)
     name = "project-%s-component-%s" % (proj, rndstr())
     component = self.jira.create_component(
         name,
         proj,
         description="test!!",
         assigneeType="COMPONENT_LEAD",
         isAssigneeTypeValid=False,
     )
     self.assertEqual(component.name, name)
     self.assertEqual(component.description, "test!!")
     self.assertEqual(component.assigneeType, "COMPONENT_LEAD")
     self.assertFalse(component.isAssigneeTypeValid)
     component.delete()
Ejemplo n.º 8
0
    def test_agile(self):
        uniq = rndstr()
        board_name = "board-" + uniq
        sprint_name = "sprint-" + uniq
        filter_name = "filter-" + uniq

        filter = self.jira.create_filter(filter_name, "description",
                                         f"project={self.project_b}", True)

        b = self.jira.create_board(board_name, filter.id)
        assert isinstance(b.id, int)

        s = self.jira.create_sprint(sprint_name, b.id)
        assert isinstance(s.id, int)
        assert s.name == sprint_name
        assert s.state.upper() == "FUTURE"

        self.jira.add_issues_to_sprint(s.id, [self.issue_1])

        sprint_field_name = "Sprint"
        sprint_field_id = [
            f["schema"]["customId"] for f in self.jira.fields()
            if f["name"] == sprint_field_name
        ][0]
        sprint_customfield = "customfield_" + str(sprint_field_id)

        updated_issue_1 = self.jira.issue(self.issue_1)
        serialised_sprint = getattr(updated_issue_1.fields,
                                    sprint_customfield)[0]

        # Too hard to serialise the sprint object. Performing simple regex match instead.
        assert re.search(r"\[id=" + str(s.id) + ",", serialised_sprint)

        # self.jira.add_issues_to_sprint(s.id, self.issue_2)

        # self.jira.rank(self.issue_2, self.issue_1)

        sleep(
            2
        )  # avoid https://travis-ci.org/pycontribs/jira/jobs/176561534#L516
        s.delete()

        sleep(2)
        b.delete()
        # self.jira.delete_board(b.id)

        filter.delete(
        )  # must delete this filter AFTER deleting board referencing the filter
Ejemplo n.º 9
0
 def test_project_components(self):
     proj = self.jira.project(self.project_b)
     name = "component-%s from project %s" % (proj, rndstr())
     component = self.jira.create_component(
         name,
         proj,
         description="test!!",
         assigneeType="COMPONENT_LEAD",
         isAssigneeTypeValid=False,
     )
     components = self.jira.project_components(self.project_b)
     self.assertGreaterEqual(len(components), 1)
     sample = find_by_id(components, component.id)
     self.assertEqual(sample.id, component.id)
     self.assertEqual(sample.name, name)
     component.delete()
Ejemplo n.º 10
0
    def test_get_project_version_by_name(self):
        name = "version-%s" % rndstr()
        version = self.jira.create_version(name, self.project_b,
                                           "will be deleted soon")

        found_version = self.jira.get_project_version_by_name(
            self.project_b, name)
        self.assertEqual(found_version.id, version.id)
        self.assertEqual(found_version.name, name)

        not_found_version = self.jira.get_project_version_by_name(
            self.project_b, "non-existent")
        self.assertEqual(not_found_version, None)

        i = self.jira.issue(self.test_manager.project_b_issue1)
        i.update(fields={"fixVersions": [{"id": version.id}]})
        version.delete()
Ejemplo n.º 11
0
    def test_rename_version(self):
        old_name = "version-%s" % rndstr()
        version = self.jira.create_version(old_name, self.project_b,
                                           "will be deleted soon")

        new_name = old_name + "-renamed"
        self.jira.rename_version(self.project_b, old_name, new_name)

        found_version = self.jira.get_project_version_by_name(
            self.project_b, new_name)
        self.assertEqual(found_version.id, version.id)
        self.assertEqual(found_version.name, new_name)

        not_found_version = self.jira.get_project_version_by_name(
            self.project_b, old_name)
        self.assertEqual(not_found_version, None)

        i = self.jira.issue(self.test_manager.project_b_issue1)
        i.update(fields={"fixVersions": [{"id": version.id}]})
        version.delete()