Exemplo n.º 1
0
    def test_idem_make_iteration_new_case(self):
        """ Should make a iteration """
        # set up
        mock_rowcount = PropertyMock(return_value=0)
        type(self.mock_get_cur.return_value).rowcount = mock_rowcount
        self.mock_get_cur.return_value.fetchone.return_value = (1,)

        # run SUT
        iteration_id = idem_make_iteration('abc123', 3)

        # confirm that reasonable sql was executed only once
        self.mock_get_cur.return_value.execute.assert_any_call(
            # branch_id appears first because we need to stort the keys to get
            # the orderig to be consistant.
            "INSERT INTO iteration (branch_id, commit_hash) " + \
            "VALUES (%s, %s) " + \
            "RETURNING iteration_id",
            (3, 'abc123')
        )

        # confirm that we got back a good id
        self.assertEqual(type(iteration_id), type(0))

        # make sure we closed the cursor
        self.mock_get_cur.return_value.close.assert_called_once_with()
Exemplo n.º 2
0
def handle_branch_commit(repo_name,
                         feature_name,
                         branch_name,
                         commit_hash):
    """
    Ensure the api represents and associates the appropriate objects

    repo_name represented as a service and associated with,
    feature_name represented as a feature and associated with,
    branch_name represented as a branch and associated with,
    commit_hash represented as a integration

    """

    print(
        "handling branch commit ({}, {}, {}, {})".format(
            repo_name,
            feature_name,
            branch_name,
            commit_hash,
        )
    )

    service_id = idem_make_service(repo_name)
    feature_id = idem_make_feature(feature_name, service_id)
    branch_id = idem_make_branch(branch_name, feature_id)
    iteration_id = idem_make_iteration(commit_hash, branch_id)
    return {'iteration_id': iteration_id}
Exemplo n.º 3
0
    def test_idem_make_iteration_existing_case(self):
        """ Should return the existing iteration id """
        # set up
        mock_rowcount = PropertyMock(return_value=1)
        type(self.mock_get_cur.return_value).rowcount = mock_rowcount
        self.mock_get_cur.return_value.fetchone.return_value = (10,)

        # run SUT
        iteration_id = idem_make_iteration(1, 'abc123')

        # confirm we only called execute once (to get existing)
        self.assertEqual(self.mock_get_cur.return_value.execute.call_count, 1)
        # and ended up with the corect id
        self.assertEqual(iteration_id, 10)

        # make sure we closed the cursor
        self.mock_get_cur.return_value.close.assert_called_once_with()