File: test_board.py

package info (click to toggle)
python-jira 3.10.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,024 kB
  • sloc: python: 8,877; sh: 13; makefile: 7; xml: 4
file content (50 lines) | stat: -rw-r--r-- 1,530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations

from collections.abc import Iterator
from contextlib import contextmanager

from jira.resources import Board
from tests.conftest import JiraTestCase, rndstr


class BoardTests(JiraTestCase):
    def setUp(self):
        super().setUp()
        self.issue_1 = self.test_manager.project_b_issue1
        self.issue_2 = self.test_manager.project_b_issue2
        self.issue_3 = self.test_manager.project_b_issue3

        uniq = rndstr()
        self.board_name = "board-" + uniq
        self.filter_name = "filter-" + uniq

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

    def tearDown(self) -> None:
        self.filter.delete()
        super().tearDown()

    @contextmanager
    def _create_board(self) -> Iterator[Board]:
        """Helper method to create a Board."""
        board = None
        try:
            board = self.jira.create_board(
                name=self.board_name,
                filter_id=self.filter.id,
                project_ids=self.project_b,
            )
            yield board
        finally:
            if board is not None:
                board.delete()

    def test_create_and_delete(self):
        # GIVEN: The filter
        # WHEN: we create a board
        with self._create_board() as board:
            # THEN: We get a reasonable looking board
            assert isinstance(board.id, int)
        # THEN: the board.delete() method is called successfully