Ejemplo n.º 1
0
    def testGET(self):
        ay = ApiYum()
        self.assertEqual(ay.GET(), None)
        self.assertEqual(ay.GET('nope'), None)

        YumRepositories.add(YumRepositories.new(environment='test'), persist=False)
        expected = OrderedDict([('environment', 'test'), ('data', None)])
        self.assertEqual(ay.GET('test'), expected)
Ejemplo n.º 2
0
Archivo: repos.py Proyecto: masom/Puck
    def add(self, **post):
        repo = YumRepositories.new(data="", environment="")
        if post:
            fields = ['data', 'environment']
            data = self._get_data('repo', fields, post)
            self._set_data(repo, data)

            if repo.validates() and YumRepositories.add(repo):
                cherrypy.session['flash'] = "Repo successfully added"
                raise cherrypy.HTTPRedirect("/repos/index")
            cherrypy.session['flash'] = "The repository data contains errors."

        # Only list environments not having a repo.
        repos = YumRepositories.all()
        environments = Environments.all()
        envs = [env.code for env in environments]
        repos = [repo.environment for repo in repos]
        available = set(envs) - set(repos)
        return self.render("/repos/add.html", crumbs=self.crumbs, environments=environments, available=available, repo=repo)