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
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)
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'
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
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