示例#1
0
文件: mock.py 项目: simudream/changes
def revision(repository, author, message=None):
    message = message or '\n\n'.join(get_paragraphs(2))
    result = Revision(
        repository=repository, sha=uuid4().hex, author=author,
        repository_id=repository.id, author_id=author.id,
        message=message,
        branches=['default', 'foobar'],
    )
    db.session.add(result)

    return result
示例#2
0
def revision(repository, author):
    result = Revision(
        repository=repository,
        sha=uuid4().hex,
        author=author,
        message='\n\n'.join(get_paragraphs(2)),
        branches=['default', 'foobar'],
    )
    db.session.add(result)

    return result
示例#3
0
文件: fixtures.py 项目: davej/changes
    def create_revision(self, **kwargs):
        kwargs.setdefault('sha', uuid4().hex)
        if not kwargs.get('repository'):
            kwargs['repository'] = self.create_repo()
        kwargs['repository_id'] = kwargs['repository'].id

        if not kwargs.get('author'):
            kwargs['author'] = self.create_author()
        kwargs['author_id'] = kwargs['author'].id

        if not kwargs.get('message'):
            message = get_sentences(1)[0][:128] + '\n'
            message += '\n\n'.join(get_paragraphs(2))
            kwargs['message'] = message

        revision = Revision(**kwargs)
        db.session.add(revision)
        db.session.commit()

        return revision
示例#4
0
def test_simple():
    revision = Revision(
        sha='33846695b2774b29a71795a009e8168a',
        repository=Repository(),
        author=Author(
            name='Foo Bar',
            email='*****@*****.**',
        ),
        parents=['a' * 40],
        branches=['master'],
        message='hello world',
        date_created=datetime(2013, 9, 19, 22, 15, 22),
    )
    result = serialize(revision)
    assert result['id'] == '33846695b2774b29a71795a009e8168a'
    assert result['author']['name'] == 'Foo Bar'
    assert result['author']['email'] == '*****@*****.**'
    assert result['message'] == 'hello world'
    assert result['dateCreated'] == '2013-09-19T22:15:22'
    assert result['parents'] == ['a' * 40]
    assert result['branches'] == ['master']