Giter VIP home page Giter VIP logo

keg-app-cookiecutter's People

Contributors

bchopson avatar bladams avatar calebsyring avatar dependabot[bot] avatar guruofgentoo avatar matthiaswh avatar mtbrock avatar rsyring avatar tjlevel12 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keg-app-cookiecutter's Issues

Adjust flash alerts

Add alembic migration for initial models

The cookiecutter includes three example models (Blog, Comment, and User), but no matching alembic migration files.

A migration for the User model, at least, would be a handy addition to the cookiecutter.

is the circleci/python:3.X image sufficient for our production apps?

I'm currently using the circleci/python:3.X images to run our tests. I did it because CircleCI caches Docker images per physical host and our Level 12 images aren't used much, so most of the time, our image has to be pulled. But, the CircleCi images are usually cached, so the tests run much faster.

But, we build our images with some libraries that our apps need, so this may not be sufficient. If it's not sufficient, then maybe we should build our python Docker images off of the CircleCi ones so that most of the layers that need to be pulled are cached.

Add grid support

Should probably put GridView and company in Keg Elements and then put example usage in this cookiecutter:

class GridView(AuthenticatedView):
    grid_cls = None
    template = 'grid-view.html'
    title = None

    def get(self):
        return self.render_grid()

    def render_grid(self):
        if self.grid_cls is None:
            raise NotImplementedError(
                'You must set {}.grid_cls to render a grid'.format(self.__class__.__name__)
            )

        g = self.grid_cls()
        g.apply_qs_args()

        if hasattr(self, 'setup_grid'):
            self.setup_grid(g)

        if g.export_to == 'xls':
            if g.xls is None:
                raise DependencyError('The xlwt library has to be installed for Excel export.')
            raise ImmediateResponse(g.xls.as_response())

        template_args = {
            'grid': g,
            'title': self.title,
        }

        return flask.render_template(self.template, **template_args)

The example above is from RaceBetter.

Add Keg-Login support

ATech integration of Keg-Login:

pytest warning regarding TestApp

rapid/tests/test_views.py::TestApp
  cannot collect test class 'TestApp' because it has a __init__ constructor

-- Docs: http://doc.pytest.org/en/latest/warnings.html

Consider setting CELERY config as individual variables

Due to the way Celery 4.0 handles configuration:

http://docs.celeryproject.org/en/latest/userguide/configuration.html#new-lowercase-settings

It seemed better to me to just have a single CELERY variable in our app's config and pass whatever is in that when we setup the Celery app.

However, the disadvantage of that approach is that you can't easily inherit settings from configuration options lower in the stack. Right now, we have to have CELERY defined in lots of places. If we moved to single config variables, then we could have defaults in DefaultProfile and everything else would inherit and override what is needed.

refs #21

Create a user for the primary developer upon DB init

Could do this in Keg Auth, but since the app is likely to customize the user, maybe we should do it in the app instead?

Can tie into Keg's db_init_post signal or, as long as DatabaseManager is being customized in app.py can just do:

    def db_init(self):
        super().db_init()
        # If all the developer variables are set, then create our first user.
        try:
            ents.User.add(
                name=self.app.config['DEVELOPER_NAME'],
                email=self.app.config['DEVELOPER_EMAIL'],
                password=self.app.config['DEVELOPER_PASSWORD'],
                is_verified=True,
            )
        except KeyError:
            pass

Add pytest assert rewrites for libs.testing

Example from Keg Auth's conftest.py file:

# Because our tests are in keg_auth.testing, which isn't a test module, pytest won't rewrite the
# assertions by default.
pytest.register_assert_rewrite('keg_auth.testing')

We have testing helper libraries, like the GridAssertions class that have asserts. When the asserts fail, we don't get helpful info from py.test unless we do a little custom config per the above.

Create Slack integration for this project

I have the sense of this repo also becoming a source of best practices. If that is the case, notifications to #dev may be helpful, just like we do for Ansible roles.

Add authenticated test app to test_views.py

class ViewBase(object):
    uses_auth = False

    @classmethod
    def testapp_login(cls, user=None):
        if not user:
            user = ents.User.testing_create()
        ta = webtest.TestApp(flask.current_app)
        resp = ta.get('/login')
        resp.form['email'] = user.email
        resp.form['password'] = user._plaintext_pass
        resp = resp.form.submit()
        assert ('success', 'Login successful.') in resp.flashes
        return ta, user

    @classmethod
    def setup_class(cls):
        # anonymous user
        cls.ta = webtest.TestApp(flask.current_app)
        if cls.uses_auth:
            cls.authta, cls.auth_user = cls.testapp_login()


class TestPublic(ViewBase):

    def test_home(self):
        resp = self.ta.get('/')
        assert resp.status_code == 302
        assert '/login' in resp.headers['Location']

    @mock.patch('tang.views.public.log', autospec=True, spec_set=True)
    def test_ping_db(self, m_log):
        resp = self.ta.get('/ping-db')
        assert 'tang ok' in resp.text
        m_log.info.assert_called_once_with('ping-db ok')


class TestPrivateViews(ViewBase):
    uses_auth = True

    def test_something(self):
       pass

move extensions to .extensions

It's problematic to have the extensions initialized in .app as views can't then import from .app to get things like csrf.

See RB app for an example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.