Ejemplo n.º 1
0
    def create_change(self, project, **kwargs):
        kwargs.setdefault('label', 'Sample')

        change = Change(hash=uuid4().hex,
                        repository=project.repository,
                        project=project,
                        **kwargs)
        db.session.add(change)
        db.session.commit()

        return change
Ejemplo n.º 2
0
    def post(self, project, label, key=None, author=None, message=None,
             date_created=None, date_modified=None):
        repository = Repository.query.get(project.repository_id)

        change = Change(
            project=project,
            repository=repository,
            author=author,
            label=label,
        )
        db.session.add(change)

        return self.respond(change)
Ejemplo n.º 3
0
def test_simple():
    change = Change(
        id=UUID(hex='33846695b2774b29a71795a009e8168a'),
        label='Hello world',
        project=Project(slug='test', name='test'),
        date_created=datetime(2013, 9, 19, 22, 15, 22),
        date_modified=datetime(2013, 9, 19, 22, 15, 23),
    )
    result = serialize(change)
    assert result['name'] == 'Hello world'
    assert result[
        'link'] == 'http://example.com/changes/33846695b2774b29a71795a009e8168a/'
    assert result['id'] == '33846695b2774b29a71795a009e8168a'
    assert result['dateCreated'] == '2013-09-19T22:15:22'
    assert result['dateModified'] == '2013-09-19T22:15:23'
Ejemplo n.º 4
0
def change(project, **kwargs):
    if 'message' not in kwargs:
        kwargs['message'] = '\n\n'.join(get_paragraphs(2))

    if 'label' not in kwargs:
        diff_id = 'D{0}'.format(random.randint(1000, 1000000000000))
        kwargs['label'] = '{0}: {1}'.format(
            diff_id, kwargs['message'].splitlines()[0])[:128]
    else:
        diff_id = None

    if 'hash' not in kwargs:
        kwargs['hash'] = sha1(diff_id or uuid4().hex).hexdigest()

    kwargs.setdefault('repository', project.repository)

    result = Change(project=project, **kwargs)
    db.session.add(result)
    return result
Ejemplo n.º 5
0
def test_simple():
    job = Job(
        id=UUID(hex='33846695b2774b29a71795a009e8168a'),
        label='Hello world',
        project=Project(slug='test', name='test'),
        date_created=datetime(2013, 9, 19, 22, 15, 22),
        date_started=datetime(2013, 9, 19, 22, 15, 23),
        date_finished=datetime(2013, 9, 19, 22, 15, 33),
        build=Build(id=UUID('1e7958a368f44b0eb5a57372a9910d50'), ),
        build_id=UUID('1e7958a368f44b0eb5a57372a9910d50'),
        change=Change(
            id=UUID(hex='2e18a7cbc0c24316b2ef9d41fea191d6'),
            label='Hello world',
        ),
    )
    result = serialize(job)
    assert result['name'] == 'Hello world'
    assert result['id'] == '33846695b2774b29a71795a009e8168a'
    assert result['dateCreated'] == '2013-09-19T22:15:22'
    assert result['dateStarted'] == '2013-09-19T22:15:23'
    assert result['dateFinished'] == '2013-09-19T22:15:33'
    assert result['duration'] == 10000