def test_unknown(self): repo = Repository( url='http://example.com/git-repo', backend=RepositoryBackend.unknown, ) result = repo.get_vcs() assert result is None
def test_git(self): repo = Repository( url='http://example.com/git-repo', backend=RepositoryBackend.git, ) result = repo.get_vcs() assert type(result) == GitVcs
def test_hg(self): repo = Repository( url='http://example.com/git-repo', backend=RepositoryBackend.hg, ) result = repo.get_vcs() assert type(result) == MercurialVcs
def post(self): args = self.parser.parse_args() slug = str(args.slug or args.name.replace(' ', '-').lower()) match = Project.query.filter( Project.slug == slug, ).first() if match: return '{"error": "Project with slug %r already exists"}' % (slug,), 400 repository = Repository.get(args.repository) if repository is None: repository = Repository( url=args.repository, ) db.session.add(repository) project = Project( name=args.name, slug=slug, repository=repository, ) db.session.add(project) db.session.commit() return self.respond(project)
def post(self, project_id): project = Project.get(project_id) if project is None: return '', 404 args = self.post_parser.parse_args() if args.name: project.name = args.name if args.slug: match = Project.query.filter( Project.slug == args.slug, Project.id != project.id, ).first() if match: return '{"error": "Project with slug %r already exists"}' % (args.slug,), 400 project.slug = args.slug if args.repository: repository = Repository.get(args.repository) if repository is None: return '{"error": "Repository with url %r does not exist"}' % (args.repository,), 400 project.repository = repository db.session.add(project) data = self.serialize(project) data['repository'] = self.serialize(project.repository) return self.respond(data, serialize=False)
def create_repo(self, **kwargs): kwargs.setdefault('url', 'http://example.com/{0}'.format(uuid4().hex)) repo = Repository(**kwargs) db.session.add(repo) db.session.commit() return repo
def repository(**kwargs): if 'url' not in kwargs: kwargs['url'] = 'https://github.com/example-{0}/example.git'.format( random.randint(1, 100000)) try: result = Repository.query.filter_by(url=kwargs['url'])[0] except IndexError: result = Repository(**kwargs) db.session.add(result) return result
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']
def post(self, project_id): project = Project.get(project_id) if project is None: return '', 404 args = self.post_parser.parse_args() if args.name: project.name = args.name if args.slug: match = Project.query.filter( Project.slug == args.slug, Project.id != project.id, ).first() if match: return '{"error": "Project with slug %r already exists"}' % ( args.slug, ), 400 project.slug = args.slug if args.repository: repository = Repository.get(args.repository) if repository is None: return '{"error": "Repository with url %r does not exist"}' % ( args.repository, ), 400 project.repository = repository if args.status == 'inactive': project.status = ProjectStatus.inactive elif args.status == 'active': project.status = ProjectStatus.active db.session.add(project) data = self.serialize(project) data['repository'] = self.serialize(project.repository) return self.respond(data, serialize=False)
def post(self): args = self.post_parser.parse_args() match = Repository.query.filter(Repository.url == args.url, ).first() if match: return '{"error": "Repository with url %r already exists"}' % ( args.url, ), 400 repo = Repository( url=args.url, backend=RepositoryBackend[args.backend], status=RepositoryStatus.importing, ) db.session.add(repo) db.session.commit() import_repo.delay( repo_id=repo.id.hex, task_id=repo.id.hex, ) return self.respond(repo)
def post(self): args = self.post_parser.parse_args() slug = str(args.slug or args.name.replace(' ', '-').lower()) match = Project.query.filter(Project.slug == slug, ).first() if match: return '{"error": "Project with slug %r already exists"}' % ( slug, ), 400 repository = Repository.get(args.repository) if repository is None: return '{"error": "Repository with url %r does not exist"}' % ( args.repository, ), 400 project = Project( name=args.name, slug=slug, repository=repository, ) db.session.add(project) db.session.commit() return self.respond(project)
def _create_repository(self): return Repository( url='http://example.com/git-repo', backend=RepositoryBackend.git, )
def test_git(self): repo = Repository(url="http://example.com/git-repo", backend=RepositoryBackend.git) result = repo.get_vcs() assert type(result) == GitVcs
def test_unknown(self): repo = Repository(url="http://example.com/git-repo", backend=RepositoryBackend.unknown) result = repo.get_vcs() assert result is None
def test_hg(self): repo = Repository(url="http://example.com/git-repo", backend=RepositoryBackend.hg) result = repo.get_vcs() assert type(result) == MercurialVcs