A feature flipper for Django

Related tags

Testingdjango-waffle
Overview
Comments
  • Added autocreate settings to fix #44

    Added autocreate settings to fix #44

    This patch makes it possible for Waffles to automatically create switches upon usage so you don't have to manually create them.

    This fixes ticket https://github.com/jsocol/django-waffle/issues/44

    opened by wolph 22
  • Django 3 support.

    Django 3 support.

    Closes #354.

    Django 3 "remove[s] private Python 2 compatibility APIs", which is to say it removes a number of utility methods that were either already provided by six or otherwise were used in bridging the old and the new python. This pull request makes django-waffle work with Django 3 by making just 3 changes.

    1. Add six to the requirements.
    2. Replace the result of callingavailable_attrs with functools.WRAPPER_ASSIGNMENTS (cf https://docs.djangoproject.com/en/2.2/_modules/django/utils/decorators/)
    3. Use the python_2_unicode_compatible provided by six rather than the one vendored with django.

    Not sure what the protocol is on bumping the version and amending the changelog; would be happy to do both.

    opened by heydenberk 21
  • Ensure flags, switches, and samples are read from write DB

    Ensure flags, switches, and samples are read from write DB

    In an environment with sufficiently high traffic and DB replication set up, there is a race condition with switches and samples where when an update is immediately followed by a read, the read will get a stale value from the DB replica and cache it.

    This fixes the race condition by ensuring that switches and samples are always read from the write DB.

    opened by dtao 18
  • Django 1.7 compatibility

    Django 1.7 compatibility

    • Export signals handling to models.py
    • Export all settings to one unique file
    • Export keyfmt to utils.py
    • We are not importing models anymore in init.py which can cause in several cases multiple fails from django.apps Registry
    • Refactor unittests using django own DiscoverRunner

    Currently all tests pass except SwitchTests.test_no_query which I'm missing something why we should make on query as we don't cache query from Django itself (we only cache proxies from waffle.__init__.py).

    I'm available if you want more information.

    This PR is currently under development and not available to merge btw.

    opened by thoas 15
  • Fix Django 1.5 User model importing

    Fix Django 1.5 User model importing

    I get a circular import problem in my Django 1.5 app caused by waffle getting the user model incorrectly.

    From the docs:

    When you define a foreign key or many-to-many relations to the User model, you should specify the custom model using the AUTH_USER_MODEL setting.

    waffle.compat.User is used to define a ManyToManyField.

    stale 
    opened by izquierdo 12
  • Cleanup and fix management commands.

    Cleanup and fix management commands.

    • Ensure that new switch is not created unless the --create flag is passed.
    • Add tests to ensure no regression for the --create fix on all commands.
    • Add separate positional arguments for commands (instead of "positionals") to improve the --help documentation.
    opened by villiers-s 11
  • Call for Maintainer Help

    Call for Maintainer Help

    To answer @clintonb's question in #245—perhaps it's already obvious—this project has not been high on my list lately, due to any number of factors (I don't write a lot of Python day-to-day at the moment, weekends have been nice outside lately, others).

    To keep the project alive will need the support of more maintainers. I love to add two or three folks to GitHub and PyPI who

    1. use Waffle in their day jobs / active projects;
    2. have at least opened a PR, even if I haven't merged it;
    3. want to see Waffle improve, hopefully beyond their immediate needs; and
    4. care about making open source a welcoming and inclusive space.

    If you'd like to help out (I suspect a couple of folks from #245, #243, #241, #226 and other recent issues might be willing, but don't want to assume) please comment here or email me, and let me know your PyPI username.

    opened by jsocol 11
  • Add Django 1.10.x test environment and fix broken tests

    Add Django 1.10.x test environment and fix broken tests

    Hi James,

    Just a small one here to get the project's test suite up to current speed.

    Tox now runs the test suite successfully under the latest Django 1.10.x and Python 3.6 environments.

    As part of making the tests run under the new environement, the tests were updated to account for deprecated behaviour in Django. Only thing of note really is that render_to_response was removed in favour of render as render_to_response is 'likely pending deprecation' as of Django 1.10.

    Thanks for all your work on this, we use it extensively at Yunojuno. If the 1.10 stuff could get a release on PyPI that'd be super; if there's anything blocking that just let us know.

    Fixes #224.

    cheers, Darian

    opened by djm 11
  • Spaces in Flag/Switch/Sample's fail when using Memcache

    Spaces in Flag/Switch/Sample's fail when using Memcache

    If you're using Memcache as your cache backend and have a space in your Flag, Switch or Sample name memcache throws and error on saving. MemcachedKeyCharacterError: Control characters not allowed

    This is because with Memcache you can't have spaces in the key.

    opened by silent1mezzo 11
  • Allow to overwrite the template tag's name to avoid conflicts.

    Allow to overwrite the template tag's name to avoid conflicts.

    Avoid conflicts with other tags for example the switch/case template tag.

    This can be done by defining WAFFLE_FLAG_TAG_NAME, WAFFLE_SWITCH_TAG_NAME and/or WAFFLE_SAMPLE_TAG_NAME in the settings.py. This is all optional.

    opened by philippeowagner 10
  • Optionally create missing Flags, Samples and Switches

    Optionally create missing Flags, Samples and Switches

    Flags, Switches and Samples may be scattered throughout templates, backend code or across mulitple frontend clients. This patch provides a user with the option of having waffle create a missing Flag, Sample or Switch when one is requested but does not exist.

    The goal of this change is to save operators time by removing the need to search through code for flag/switch/sample names and to reduce communication requirements accross teams with of multiple developers with multiple environments that might require the creation of a flag/switch/sample in the database of every environment code is run in.

    Behavior Changes

    Old Behavior

    1. Flag/Switch/Sample is requested 2a. If found in db evaulate what the value should be for request 2b. If missing return (FLAG|SWITCH|SAMPLE)_DEFAULT value

    New Behavior

    1. Flag/Switch/Sample is requested 2a. If found in db evaulate what the value should be for request 2b. Create Flag/Switch/Sample with value (FLAG|SWITCH|SAMPLE)_DEFAULT
    2. Return (FLAG|SWITCH|SAMPLE)_DEFAULT for this request, subsequent requests will be served using the value from the cache/db

    Further Discussion

    • #44 (https://github.com/jsocol/django-waffle/issues/44)
    • #50 (https://github.com/jsocol/django-waffle/issues/50)

    Future Work

    This change intentionally narrowly scoped and as such does not provide a mechanism to set a default value other than (FLAG|SWITCH|SAMPLE)_DEFAULT for individual objects that are not in the database although it could be expanded in the future to do so.

    opened by adamhaney 9
  • Consolidate config settings for handling missing entities

    Consolidate config settings for handling missing entities

    The problem

    I ran into an error that occured due to a typo in the name of a waffle flag in my code. It would have been much better (IMO), and the bug would have been picked up much earlier, had flat_is_active failed hard for non-existent flags. Failing silently can be dangerous, and whilst I appreciate I can set WAFFLE_LOG_MISSING_FLAGS to logging.ERROR to increase visibility, this will still not cause a request to fail hard. In development environments, I tend not to pay particular attention to logs unless I'm specifically looking for something. However, a hard failure would pick up the typo before it makes it way to production.

    Is this configuration bloat??

    Obviously, not everyone would want the behaviour I suggest above (quite apart from the fact that it would be a breaking change). As such, an extra configuration setting such as WAFFLE_RAISE_MISSING_FLAGS would be needed. There are currently quite a lot of configuration settings for waffle. For each of FLAG, SWITCH and SAMPLE we have:

    • WAFFLE_*_DEFAULT
    • WAFFLE_CREATE_MISSING_*S
    • WAFFLE_LOG_MISSING_*S

    With this in mind, we probably do not want an extra configuration setting. There are no doubt other behaviours that other uses would wish for in the case of a missing flag, and it's untenable to provide a new setting for each of them.

    A proposed solution

    Instead of introducing a new config setting, I propose that we replace WAFFLE_CREATE_MISSING_*S and WAFFLE_LOG_MISSING_*S with a new setting WAFFLE_HANDLE_MISSING_*S which would be a string that points to a function that would be called when an entity is missing. For example:

    # settings.py
    WAFFLE_HANDLE_MISSING_FLAGS = "some_file.handle_missing_flags"
    
    # some_file.py
    def handle_missing_flags(name):
        # potentially log a message, create a flag and do anything else you want
        # optionally return a flag
    

    (If a flag is returned the flag would be cached, and the value from the flag would be used, otherwise the default value would be used - as is the current behaviour).

    This would have several advantages.

    • The default function would use the existing WAFFLE_CREATE_MISSING_*S and WAFFLE_LOG_MISSING_*S settings so that introducing the setting would result in no change in behaviour.
    • We can then utilise the django checks framework to provide warnings that the old settings will eventually be deprecated, and in time update those warnings to errors. Suitable documentation could also be provided to guide migration to the new system (although this should be reasonably straight-forward). This will mean a pleasant deprecation timeline.
    • This allows users greater flexibility to provide the individual functionality they want.
    • This actually reduces the number of configuration settings whilst protecting against future settings bloat.

    (Part of me would like to subsume WAFFLE_*_DEFAULT into the new setting too, but seeing as the default values are used in WaffleJS this would be difficult.)

    If there is support for this proposition I would be more than happy to submit a PR. I look forward to any feedback on the above.

    opened by tim-mccurrach 0
  • feat: Allow override_flag testutil to set different checks

    feat: Allow override_flag testutil to set different checks

    Up until now, the override_flag test util was only useful to completely activate or deactivate a flag. It didn't allow to provide more customization for all the internal checks it makes, like evaluating if the request user is authenticated or staff.

    This change provides that functionality, without breaking the current API, to avoid breaking changes. Now, users can provide more granular arguments to override_flag, for a more flexible flag testing.

    Closes #439.

    opened by adamantike 0
  • TypeError: is_active() got an unexpected keyword argument 'read_only'

    TypeError: is_active() got an unexpected keyword argument 'read_only'

    I am upgrading from django-waffle==0.19.0 to current django-waffle on Django 3.1. I am getting the above TypeError which seems to be related to the changes made in #447. Are there any hints on how to modify existing code the deal with the read_only change?

    opened by cclauss 1
  • `WAFFLE_SWITCH_MODEL` is missing from the

    `WAFFLE_SWITCH_MODEL` is missing from the "Configuring Waffle" docs page

    The setting WAFFLE_SWITCH_MODEL allows using a custom switch model. It's documented on the Switches page but not on the Configuring Waffle page. For comparison, the equivalent setting for flags, WAFFLE_FLAG_MODEL, is documented on both the Flags and Configuring Waffle pages.

    Perhaps there are other settings missing from the Configuring Waffle page? I haven't checked.

    opened by allanlewis 2
  • Enable pytest support for django waffle

    Enable pytest support for django waffle

    It would be very useful if testing utils such as override_switch and override_flag were available for pytest style classes as class decorators. Is this feature somewhere on the road map?

    opened by rievva-aleksandra 3
  • New view to expose flag state as JSON

    New view to expose flag state as JSON

    Waffle currently has a view to expose flag state as Javascript via the WaffleJS endpoint.

    But there are a number of use cases, e.g. backend API calls, where it would be preferable to expose that state in a serialized format like JSON.

    For use cases like an audit dashboard, the view might also expose metadata such as the total number of active and and inactive flags of each type, and the number of stale flags (i.e. more than X days since last toggled).

    I propose a new backend function that queries the database and returns this data, and a new endpoint that returns the data as JSON.

    opened by shaungallagher 3
Releases(v3.0.0)
  • v3.0.0(Aug 30, 2022)

    What's Changed

    • Update Github actions by @ulgens in https://github.com/django-waffle/django-waffle/pull/459
    • Pluggable Switch and Sample models #456 by @cole-jacobs in https://github.com/django-waffle/django-waffle/pull/457
    • Remove support for EOL Python versions by @ulgens in https://github.com/django-waffle/django-waffle/pull/460
    • Update Django versions by @ulgens in https://github.com/django-waffle/django-waffle/pull/461

    New Contributors

    • @ulgens made their first contribution in https://github.com/django-waffle/django-waffle/pull/459
    • @cole-jacobs made their first contribution in https://github.com/django-waffle/django-waffle/pull/457

    Full Changelog: https://github.com/django-waffle/django-waffle/compare/v2.7.0...v3.0.0

    Source code(tar.gz)
    Source code(zip)
  • v2.7.0(Aug 22, 2022)

    What's Changed

    • Expose JSON endpoint for Waffle flag/switch/sample state by @shaungallagher in https://github.com/django-waffle/django-waffle/pull/452

    Full Changelog: https://github.com/django-waffle/django-waffle/compare/v2.6.0...v2.7.0

    Source code(tar.gz)
    Source code(zip)
  • v2.6.0(Jul 20, 2022)

    What's Changed

    • Fixed Django 4.0 compatibility by @triopter in https://github.com/django-waffle/django-waffle/pull/446
    • Added support for custom Sample and Switch models by @shaungallagher in https://github.com/django-waffle/django-waffle/pull/448
    • Added ability to determine if flag is active without persisting new state by @triopter in https://github.com/django-waffle/django-waffle/pull/447
    • Added support for Python 3.10 by @clintonb in https://github.com/django-waffle/django-waffle/pull/450

    New Contributors

    • @triopter made their first contribution in https://github.com/django-waffle/django-waffle/pull/446
    • @shaungallagher made their first contribution in https://github.com/django-waffle/django-waffle/pull/448

    Full Changelog: https://github.com/django-waffle/django-waffle/compare/v2.5.0...v2.6.0

    Source code(tar.gz)
    Source code(zip)
  • v2.5.0(Jun 5, 2022)

    What's Changed

    • fix wording error by @simonkern in https://github.com/django-waffle/django-waffle/pull/440
    • Add config to support disabling admin pages by default. by @onurhunce-planetly in https://github.com/django-waffle/django-waffle/pull/444

    New Contributors

    • @onurhunce-planetly made their first contribution in https://github.com/django-waffle/django-waffle/pull/444

    Full Changelog: https://github.com/django-waffle/django-waffle/compare/v2.4.1...v2.5.0

    Source code(tar.gz)
    Source code(zip)
  • v2.4.1(Mar 28, 2022)

  • v2.4.0(Mar 28, 2022)

    • Preventing exceptions for template use cases where a request is not available
    • Creating missing flags for all attempts to access the missing flag
    • Added Italian translations
    • Removed universal wheel
    Source code(tar.gz)
    Source code(zip)
  • v2.3.0(Jan 10, 2022)

  • v2.2.1(Jul 13, 2021)

  • v2.2.0(May 21, 2021)

  • v2.1.0(Jan 22, 2021)

  • v2.0.0(Sep 3, 2020)

  • v1.0.0(Jun 22, 2020)

  • v0.20.0(Feb 15, 2020)

  • v0.19.0(Jan 9, 2020)

    • Dropped support for Django 2.0 and 2.1, and Python 3.4
    • Made tests for Jinja2 optional while waiting for django-jinja to be compatible with Django 3.0.
    • Add support for Django 3.0 by removing use of deprecated functionality from Django 2.2.
    Source code(tar.gz)
    Source code(zip)
  • v0.18.0(Nov 3, 2019)

    • Updated MIDDLEWARE setting name for Django 1.10+
    • Improved cache performance for is_active_for_user
    • Corrected log formatting
    • Added log entries for admin quick link actions
    • Added permissions for admin actions
    Source code(tar.gz)
    Source code(zip)
  • v0.17.0(Jul 1, 2019)

  • v0.16.0(Apr 4, 2019)

    • Added support for Django 2.1 and 2.2
    • Flushing cache after modifying flags' groups and users
    • Removed redundant log line
    • Corrected version in waffle/__init__.py
    • Fixed bug in tests
    • Using strings as cache keys instead of bytes
    • Passing effects of test decorator to child classes
      • NOTE: This introduced a backwards-incompatible change for the testutils override decorators. See https://github.com/django-waffle/django-waffle/pull/331 for details.
    Source code(tar.gz)
    Source code(zip)
  • v0.15.1(Jan 9, 2019)

    • Optionally logging missing flags, samples, and switches
    • Added --users option to waffle_flag management command
    • Updated testutils to flush caches
    • Improved admin site for users and groups
    • Fixed global cache thread safety issues
    Source code(tar.gz)
    Source code(zip)
  • v0.15.0(Nov 5, 2018)

    • Dropped support for Django < 1.11
    • Dropped support for Python 3.3
    • Added settings WAFFLE_CREATE_MISSING_(FLAG|SWITCHES|SAMPLES) to optionally create missing objects in the database automatically
    • Allow serializing/de-serializing waffle models by natural key
    • Added pluggable Flag model
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Mar 6, 2018)

  • v0.13.0(Jan 24, 2018)

    • Added support for Django 2.0.
    • Added support for search the name and notes fields in Django admin.
    • Fixed small bugs in management commands.
    • Fixed small documentation issues.
    • Updated waffle_flag management command to accept user groups.
    • Added setting WAFFLE_READ_FROM_WRITE_DB to read from write DB on cache miss.
    Source code(tar.gz)
    Source code(zip)
  • v0.12.0a1(May 30, 2016)

    This alpha contains a little more than half of the changes expected to go into 0.12, but it does not contain the settings/API changes from #182.

    Definitely looking for feedback on this version, especially with the caching changes from #211. Those look to significantly simplify how caching works, and will have the most noticeable performance improvements while using wafflejs (see #77, #170).

    To install, you can use pip:

    pip install https://github.com/jsocol/django-waffle/archive/v0.12.0a1.zip
    

    Please file issues and mention this version.

    Source code(tar.gz)
    Source code(zip)
A small faсade for the standard python mocker library to make it user-friendly

unittest-mocker Inspired by the pytest-mock, but written from scratch for using with unittest and convenient tool - patch_class Installation pip insta

Vertliba V.V. 6 Jun 10, 2022
Minimal example of how to use pytest with automated 'devops' style automated test runs

Pytest python example with automated testing This is a minimal viable example of pytest with an automated run of tests for every push/merge into the m

Karma Computing 2 Jan 02, 2022
Flexible test automation for Python

Nox - Flexible test automation for Python nox is a command-line tool that automates testing in multiple Python environments, similar to tox. Unlike to

Stargirl Flowers 941 Jan 03, 2023
It's a simple script to generate a mush on code forces, the script will accept the public problem urls only or polygon problems.

Codeforces-Sheet-Generator It's a simple script to generate a mushup on code forces, the script will accept the public problem urls only or polygon pr

Ahmed Hossam 10 Aug 02, 2022
Network automation lab using nornir, scrapli, and containerlab with Arista EOS

nornir-scrapli-eos-lab Network automation lab using nornir, scrapli, and containerlab with Arista EOS. Objectives Deploy base configs to 4xArista devi

Vireak Ouk 13 Jul 07, 2022
A folder automation made using Watch-dog, it only works in linux for now but I assume, it will be adaptable to mac and PC as well

folder-automation A folder automation made using Watch-dog, it only works in linux for now but I assume, it will be adaptable to mac and PC as well Th

Parag Jyoti Paul 31 May 28, 2021
Run ISP speed tests and save results

SpeedMon Automatically run periodic internet speed tests and save results to a variety of storage backends. Supported Backends InfluxDB v1 InfluxDB v2

Matthew Carey 9 May 08, 2022
Python tools for penetration testing

pyTools_PT python tools for penetration testing Please don't use these tool for illegal purposes. These tools is meant for penetration testing for leg

Gourab 1 Dec 01, 2021
A test fixtures replacement for Python

factory_boy factory_boy is a fixtures replacement based on thoughtbot's factory_bot. As a fixtures replacement tool, it aims to replace static, hard t

FactoryBoy project 3k Jan 05, 2023
Multi-asset backtesting framework. An intuitive API lets analysts try out their strategies right away

Multi-asset backtesting framework. An intuitive API lets analysts try out their strategies right away. Fast execution of profit-take/loss-cut orders is built-in. Seamless with Pandas.

Epymetheus 39 Jan 06, 2023
pytest_pyramid provides basic fixtures for testing pyramid applications with pytest test suite

pytest_pyramid pytest_pyramid provides basic fixtures for testing pyramid applications with pytest test suite. By default, pytest_pyramid will create

Grzegorz Śliwiński 12 Dec 04, 2022
The Penetration Testers Framework (PTF) is a way for modular support for up-to-date tools.

The PenTesters Framework (PTF) is a Python script designed for Debian/Ubuntu/ArchLinux based distributions to create a similar and familiar distribution for Penetration Testing

trustedsec 4.5k Dec 28, 2022
Enabling easy statistical significance testing for deep neural networks.

deep-significance: Easy and Better Significance Testing for Deep Neural Networks Contents ⁉️ Why 📥 Installation 🔖 Examples Intermezzo: Almost Stocha

Dennis Ulmer 270 Dec 20, 2022
Aioresponses is a helper for mock/fake web requests in python aiohttp package.

aioresponses Aioresponses is a helper to mock/fake web requests in python aiohttp package. For requests module there are a lot of packages that help u

402 Jan 06, 2023
A web scraping using Selenium Webdriver

Savee - Images Downloader Project using Selenium Webdriver to download images from someone's profile on https:www.savee.it website. Usage The project

Caio Eduardo Lobo 1 Dec 17, 2021
Free cleverbot without headless browser

Cleverbot Scraper Simple free cleverbot library that doesn't require running a heavy ram wasting headless web browser to actually chat with the bot, a

Matheus Fillipe 3 Sep 25, 2022
bulk upload files to libgen.lc (Selenium script)

LibgenBulkUpload bulk upload files to http://libgen.lc/librarian.php (Selenium script) Usage ./upload.py to_upload uploaded rejects So title and autho

8 Jul 07, 2022
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.

The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-

Kirill Klenov 871 Dec 25, 2022
Pymox - open source mock object framework for Python

Pymox is an open source mock object framework for Python. First Steps Installation Tutorial Documentation http://pymox.readthedocs.io/en/latest/index.

Ivan Rocha 7 Feb 02, 2022
✅ Python web automation and testing. 🚀 Fast, easy, reliable. 💠

Build fast, reliable, end-to-end tests. SeleniumBase is a Python framework for web automation, end-to-end testing, and more. Tests are run with "pytes

SeleniumBase 3k Jan 04, 2023