Esempio n. 1
0
def test_move_issues():
    config = Configuration(os.path.join(MOCK_FOLDER_PATH, 'conf.ini'))
    config.load_properties()
    issue = Issue(id="1",
                  title="title",
                  number=1,
                  assignees=["Rony"],
                  labels=["Testing"],
                  card_id_to_project={"sdf": {
                      "project_number": 1
                  }})
    project = Project(name="test project",
                      config=config,
                      columns={
                          "Queue":
                          ProjectColumn(
                              id="id",
                              name="Queue",
                              cards=[IssueCard(id="sdf", issue=issue)]),
                          "In progress":
                          ProjectColumn(id="id", name="In progress", cards=[])
                      })

    class MockClient(object):
        def add_to_column(*args, **kwargs):
            return

        def move_to_specific_place_in_column(*args, **kwargs):
            return

    project.move_issues(MockClient(), config)
    assert project.is_in_column("Queue", "1") is False
    assert project.is_in_column("In progress", "1") is True

    # Move within the same column
    project.move_issues(MockClient(), config)
    assert project.is_in_column("Queue", "1") is False
    assert project.is_in_column("In progress", "1") is True
Esempio n. 2
0
def test_move_items():
    config = Configuration(os.path.join(MOCK_FOLDER_PATH, 'conf.ini'))
    config.load_properties()
    issue = Issue(id="1",
                  title="title",
                  number=1,
                  assignees=["Rony"],
                  labels=["Testing"],
                  card_id_to_project={
                      "sdf": {
                          "project_number": 1
                      }
                  }
                  )
    pull_request = PullRequest(id="10",
                               title="title",
                               number=10,
                               assignees=["Daud"],
                               labels=["Testing"],
                               card_id_to_project={
                                   "dsf": {
                                       "project_number": 1
                                   }
                               })
    project = Project(
        name="test project",
        config=config,
        columns={
            "Queue": ProjectColumn(id="id", name="Queue",
                                   cards=[ItemCard(id="sdf",
                                                   item=issue),
                                          ItemCard(id="dsf",
                                                   item=pull_request)
                                          ]),
            "In progress": ProjectColumn(id="id", name="In progress", cards=[])
        }
    )

    class MockClient(object):
        def add_to_column(*args, **kwargs):
            return

        def move_to_specific_place_in_column(*args, **kwargs):
            return

    project.move_items(MockClient(), config, {'1': issue})
    assert project.is_in_column("Queue", "1") is False
    assert project.is_in_column("In progress", "1") is True

    project.move_items(MockClient(), config, {'10': pull_request})
    assert project.is_in_column("Queue", "10") is False
    assert project.is_in_column("In progress", "10") is True

    # Move within the same column
    project.move_items(MockClient(), config, {'1': issue})
    assert project.is_in_column("Queue", "1") is False
    assert project.is_in_column("In progress", "1") is True

    issue.state = 'closed'
    project.move_item(MockClient(), issue, 'In progress', config)
    assert project.is_in_column("In progress", "1") is True