Граф коммитов

141 Коммитов

Автор SHA1 Сообщение Дата
Christopher Grebs 6667c90c73
Add tests for utf8mb4 encoding (#10726)
Fixes #10725
2019-02-20 20:15:18 +01:00
Christopher Grebs 04fe02162d
Remove django-product-details dependency. (#10371)
* Add new olympia.core.languages module as a replacement for supported
  languages
* Implement new ApplicationsVersions.get_latest_application_version
helper

Fixes #9516 

Fixes #8850 along the way, removes the need for #8779 and unblocks #2739
2019-01-14 14:33:56 +01:00
Christopher Grebs 2c82ea7728
Enable memcached by default for tests. Upgrade python-memcached
* Adds a test to test unicode support for latest python-memcached
  versions
* Configures caches key prefix so that tests don't conflict with each other
* Remove a few cache.clear calls with `cache.delete` calls that avoids
deleting all memcached entries while other tests are running
* Remove zadmin.memcached as it's crazy dangerous, such power should
only be wielded by ops-folks who wake up at night when pressed
* Fixes waffle helpers to call .flush() to flush appropriate caches

This also fixes how parameters are forwarded to memcached and fix KEY_PREFIX initialization

We are now making sure parameters from `settings.CACHES` are properly forwarded
to the actual cache backend (now memcached). These errors were not seen
since LocMemCache didn't require any parameters.

The `KEY_PREFIX` setting is set to a uuid instead of the xdist-slaveid to
ensure test functions are properly isolated from each other.

`cache.clear` is not called anywhere unless absolutely necessary to reduce
the side-effects of our test-setup.

Fixes #8602
2018-11-21 18:26:30 +01:00
Mathieu Pillard d7876929b3 Remove filesystem cache, use default (memcached) backend for everything
Only the language tools API used the filesystem cache, and that was
because it had a relatively low usage compared to cache-machine, which
meant everything it cached was quickly evicted. Now that cache-machine
is gone, let's use memcached again for this.
2018-07-27 11:35:42 +02:00
Christopher Grebs 7ec2b5afbb
Integrate git-release into raven messages. (#8852)
* Integrate git-release into raven messages.

This renames a few raven related settings that aren't used by the
official raven package but only set in our base templates for Raven.js
to pick them up.

This also removes a few unused settings variables.

Fixes #8851

* Fetch git commit from version.json as well.
2018-07-13 08:34:08 +02:00
Christopher Grebs 7407b70aa2
Update to Django 1.11 (#8738)
Port code and tests to Django 1.11.

* Update requirements to Django 1.11.14, remove session_csrf
* Use --run-syncdb for migration calls
* Remove unused setup-docker script
* Port code and tests to Django 1.11.
* Remove django-session-csrf everywhere, it got replaced by django's own
  session csrf protection
* Make sure we are calling `client.get()` with `follow=True` where necessary
* Replace django.core.urlresolvers import with django.urls
* Port custom `IconWidgetRenderer` to Django 1.11 as `IconTypeSelect`
* Properly use `_queryset_class` for custom manager classes
* Make use of `base_manager_name` on our models `Meta` instead of `use_for_related_objects`
  on the manager where appropriate. This is required to make translations, soft-delete
  and more work. See comment on Addons.Meta for more details.
* Various fixes along the way to make tests work
* Port form errors for locale editing forms to Django 1.11 and make use of
  form.add_error instead of our own custom process
* Mark TestDetailPage.test_304 as xfail for now, somehow Etags seem to be broken
  for that view during tests but work fine in manual tests
* Fix amo.celery, we cannot have any imports at the module-level that may
  import the ORM
* Fix global_settings context processor for 500-server error cases
* Fix `changed_data` handling in `AMOModelForm`
* Remove `queryset_transform` and implement it directly in amo/models
* Fix pagination, Django changed how `num_pages` work and how `count` can be overwritten
* Add a new test that tests database transforms as `BaseQuerysetTestCase`
* Make sure `legacy_redirect` only appends `?` if there are actual GET parameters
* Re-implement `LicenseRadioChoiceInput` as `LicenseRadioSelect` which is now Django 1.11 compatible
* Remove our custom `form_kwargs` uplift from Django 1.9
* Correct how we're using `Category.objects.create` and only pass `db_name` instead of `name`, previously
  this didn't error but now it (luckily!) does
* Update `FileSelectWidget` to correctly work with Django 1.11, use custom rendering
* Fix decorator ordering for `files.views:browse`
* Update database settings to correctly use `TEST` object
* Fix `select_related` call in `RatingViewSet`
* Remove custom `DateTimeCast` implementation
* Fix `addon_factory` calls in `reviewers/tests/test_views.py` to correctly set
  `is_webextension`
* Port our `TranslationDescriptor` and `TranslatedField` to Django 1.11. Also, make sure form error handling works
* Add a new test that checks that `default=None` is a valid setting for translation fields
* Add a new test that checks that translations from related fields are correctly fetched
* Remove possible ambiguity from translations `TestWidget` tests
* Make sure that the correct `MEDIA_URL` is set in `TestDownloadsUnlistedVersions` to fix
  external cdn tests

* Remove custom happyforms code. Django cleans text fields now by default
* Move translations app to the top of INSTALLED_APPS, add a lengthy comment
* Pass additional arguments to contribute_to_class, fix smaller nits
* Set MEDIA_URL and STATIC_URL to an external value by default. That's how they're configured in dev, stage and prod anyway.

Please note that we didn't replace all our custom form rendering with proper templated widgets yet. This will
happening in some follow-up work.

Fixes #5271, Fixes #1569
2018-07-11 06:56:54 +02:00
Christopher Grebs ceae9d4fd0
Remove cache machine (#8606)
Fixes #7743
2018-06-28 13:20:06 +02:00
Christopher Grebs a2ddf0d5f4
Avoid logging through mozlog in tests experiment (#8528)
Closes #8451 (Doesn't necessary fix it, we don't want a unified logging-level but this PR makes logging much clearer.)

* Don't use verbose mode for tox
* Refactor logging settings
* Fix services logging, correct dev and stage settings, update docs
* Update logging
* Be vigilent about disabling all logging
* Remove MOZLOG_NAME from stage settings
2018-06-18 06:10:26 -07:00
Christopher Grebs 0be2a9f77a
Merge cache_nuggets and lib.cache.
Fixes #8462

Purely code-quality to have one single point of cache-helpers.
2018-06-12 15:15:20 -07:00
Christopher Grebs 1500c53305
Implement basket <-> amo newsletter sync (#8174)
* Implement basket <-> amo newsletter sync.

* Adds basket-client dependency
* Refactors users.notifications to allow for remotely-managed
  notification types
* Implement helpers to fetch, subscribe and unsubscribe from newsletters
* Update user profile editing form to fetch and save to basket
* Update accounts/notifications endpoint to fetch and save to basket
* Implement a sync_basket command that fetches basket tokens
asynchronously for all users

All this is behind a waffle flag.

Fixes #7808

* Switch to 100% synchronous basket requests again

* Fix accounts view test to use the conftest configured token

* Fix typos and comments

* Put basket integration behind waffle flag

* Fix typo

* Fix tests

* Remove sync_basket command

* Fix flake8
2018-05-09 17:53:35 +02:00
Christopher Grebs 6a8fc341da
Remove cache-machine helpers, switch to django cache backends (#8122)
* Implement cache request tracking, add zadmin config tests.

Implements CacheStatTracker as a backend for tests to allow us to use
`assert_cache_requests` in tests.

* implement a `cached` helper and removes caching.{cached,cached_with} instances.
* change from caching backends back to django cache backends

* Move cache_helpers -> cache_nuggets

* Fix CacheStatTracker to not remove OPTIONS values
2018-04-25 16:04:20 +02:00
Andrew Williamson 55bbcb1556
Simplify settings files (#8001) 2018-04-09 22:48:02 +08:00
Mathieu Pillard c125bf9354 Implement appversion compatibility filtering in language tools API
- Allow filtering by type to only show language packs
- Expose a new current_compatible_version if appversion is passed.
- This property will fetch the latest publicly available version
  compatible with the appversion passed.
- Replace caching with a filesystem-based implementation to work
  around cache eviction issues.
2018-03-05 15:44:46 +01:00
Mathieu Pillard 3ff221a52a Run new image uploads through pngcrush, add a command to handle existing ones
Icons and previews for both themes and non-themes should go through pngcrush.
For the existing content, the command `crush_images_for_top_addons` focuses
on the content displayed on landing pages only and should only be run once.
2018-02-27 01:52:45 +01:00
Christopher Grebs c3c31665e2
Revert "Revert "Refactor our tests and code to make better use of settings.TMP_PATH""
This reverts commit 3f7fe78093.
2018-02-02 12:47:50 +01:00
Christopher Grebs 3f7fe78093
Revert "Refactor our tests and code to make better use of settings.TMP_PATH"
This reverts commit 778a94871a.
2018-01-30 14:22:23 +01:00
Christopher Grebs d52015d365
Default to 'and' operator for match queries. Remove slug search, prioritize exact matches more. (#7303)
* Default to 'and' operator for match queries. Remove slug search, prioritize exact matches more.

References many "component: search" issues. What I tested with a
database of all public add-ons:

Example searches:

tab center redux - should find "Tab Center Redux" while "Tab Mix Plus" is probably second and "Redux DevTools" 4th or so
Open Image in New Tab -> should find "Open Image in New Tab" while "Open Bookmarks in New Tab" should be 2nd or 3rd
CoinHive -> Finds "Coinhive Blocker", "CoinBlock" (prefix search) and "NoMiners" (description)
Privacy -> Finds "Privacy Badger", "Privacy Pass", "Privacy Settings", "Google Privacy" (probably 4th or so) and "Blur" (summary + description + many users). Scores "Ghostery" on the first page but ranks it in the middle
firebu -> Finds "Firebug", "Firebug Autocompleter", "Firefinder for Firebug"
fireb -> Scores "Fire Drag" first, puts "Firebug" approximately 3rd or so
Menu Wizzard -> Finds "Menu Wizard" (fuzzy, typo) first, then "Add-ons Manager Context Menu" apparently because it matches good in the title and has many users
Frame Demolition -> Finds "Frame Demolition"
Demolition -> Finds only "Frame Demolition", same for "Demolation" (typo)
reStyle -> Finds "reStyle" and scores a few add-ons that match on "restore" next since the term is similar
MegaUpload DownloadHelper -> finds "MegaUpload DownloadHelper" first, scores "Video DownloadHelper" and "RadpidShare DownloadHelper" next. Doesn't find "Popup Blocker" anymore as currently happening on -prod
MegaUpload -> only finds "MegaUpload DownloadHelper" and nothing else
No Flash -> Scores "No Flash" first, then depending on users "Download Flash and Video", "YouTube Flash Video Player" and "YouTube Flash Player" (not necessarily in that order)
Disable Hello, Pocket & Reader+ -> finds "Disable Hello, Pocket & Reader+" first (yeay!), then scores "Reader", "Disable WebRTC" and "In My Pocket" next similarly to what's happening on -prod currently

Not working yet:

privacybadger -> "Privacy Badger" -> will probably need some kind of ngram filtering and analyzing (#591)
eyes -> 'decentraleyes' -> Not sure this should actually work, will probably need some more analyzing too (#591)

Not sure if it's specifically only because of these changes but #3248 is fixed.

This potentially fixes #7244, #6891, #6837, #6417, mozilla/addons#359.

Not sure if this fixes #mozilla/addons#567 but the results look much more promising and the amount of results doesn't explode here. I only have 2.8k add-ons for testing though so I'm not too sure.

And might be relevant to #6137.

This is a big step towards #2661, I doubt we can call this fixed though.

* Fix name tests

* Speed up ES tests, make scoring results more predictable by using only one shard and one replica

* Add tests

* Only test on new apiv3 based search.

* Fixup 'get_results'

* Remove debug print

* Isort imports

* Fix test settings, I'm blind.

* Adapt number of shards to what we define in settings_test

* Test search for grapple

* Remove property filtering in legacy api search, fix tests, fix flake8

* Add comment explaining shard config

* Fix tests again, add default platform, fix total counts again.

* Try to do some fixture cleanup, let's see...

* More test refactoring, make use of dfs-query-then-fetch during tests, allow us to test this later too via a waffle flag.

* Don't use waffle flag for legacy search, only for apiv3 searches.

* Fix unused import, fix usage of 'params'

* Use query-then-fetch in a regular addons-view tool, fix a few more tests to be able to handle the waffle-flag

* Create the dfs query then fetch flag only in ESTestCase, delete it properly. More serializer fixes

* precache the waffle flag for autocomplete tests too

* Minor cleanups

* Add docs, fix code style

* Add a todo

* Fix codestyle
2018-01-30 06:26:30 +01:00
Christopher Grebs 778a94871a
Refactor our tests and code to make better use of settings.TMP_PATH
* Also let the dot in py.test die so that upstream is happy again :)
 * Update tox to 2.9.1
 * Make sure that our urlconf is reset *after* we set MEDIA_ROOT
 * Adapt file extraction handling to new TMP_PATH prefixes
 * Less dump_apps hacks since the apps.json file isn't present at the
   beginning of any test now thanks to temporary paths for every separate
   test
 * Rewrite read-only-mode tests to cope with pytest settings fixture
 * Remove atexit hack from settings_test

This will probably make things a lot easier for ui-tests as well.

Fixes #7205
Fixes #7206
2018-01-05 16:41:35 +01:00
Christopher Grebs c2b7f30d24
Add autograph signing server support (#6865)
Fixes #6640
Fixes #6866

This pull request adds support for our new Autograph signing server, adds it to our dockerized services and adds tests that now actually call our signing server.

* Add a waffle-switch for calls to our new autograph signing server
* Add the autograph signing server to docker-compose
* Add the autograph signing server to our travis setup
* avoid us specifying the signing server settings everywhere in the code, one single source of truth
* more use of `responses` instead of mocking, leaning towards
  the future where we can actually hit a signing server instead
  of a mock
* disallow http requests generically, unless configured otherwise
* Add migration for waffle flag
2017-11-13 17:29:57 +01:00
Christopher Grebs 176383b168 Upgrade to Celery 4 (#6667)
* Update celery, config and dependencies to 4.x

* Remove usage of TaskSet, replace with group(), update `ampq`
* Enable redis on travis for better celery 4.x testing
* Fix lib/celery_tests
* Correct test testing email sending retrying on errors
* Fix celery subtask mocking errors.

* Fix celery broker url env variable

* Integrate watchdog for celery autoreload

* Ensure dependencies are updated for worker and web container.

* Restart all services after the dependency update

* Remove explicit celery loader environment variable.

* Restart all services in web and worker after running 'update_docker'

* Increase sleep time a bit
2017-10-16 11:16:41 +02:00
Mathieu Pillard 43d88b4f55 Revert "Upgrade to Celery 4 (#6625)"
This reverts commit 541688d5f2.

This caused some breakage on dev. We suspect it's because newrelic
hooks into the celery task launching code but does not support
celery 4.x yet.
2017-10-13 00:04:27 +02:00
Christopher Grebs 541688d5f2 Upgrade to Celery 4 (#6625)
* Update celery config to seamlessly upgrade to 4.x

* Update celery initialization for new configs and 4.x

* Update dependencies to celery 4.x

* Fix flake8

* Fix typo

* Remove usage of TaskSet, replace with group(), update `ampq`

* Enable redis on travis for better celery 4.x testing

* Fix more test setting names

* Fix lib/celery_tests

* Correct test testing email sending retrying on errors

* Fix celery subtask mocking errors.

* Fix new line

* Fix celery broker url env variable

* Integrate watchdog for celery autoreload

* Try something weird... ui-tests

* do we need extra hosts?

* more sleep?

* Try logging, try docker run to avoid port collisions

* More debugging

* Cleanup again

* Fix logs?

* Ensure dependencies are updated for worker and web container.

* Remove not functioning log saving for onw

* Restart all services after the dependency update
2017-10-12 21:05:21 +02:00
Christopher Grebs aa1fcbd435 Remove HIDDEN_LANGUAGES, sync with .po files and product-details. (#6536)
* Remove HIDDEN_LANGUAGES, sync with .po files and product-details.

Fixes #6534, Fixes #6535 

* Remove test referencing cy language, imho it doesn't make sense to have languages lying around in the code that aren't in product-details anyway, just adds another layer of writing things down needlessly

* Add comment about bidi languages

* Add test

* Remove fa-IR from languages, we never supported it in the past.

* Remove custom locales from test settings.
2017-10-04 08:35:31 +02:00
Christopher Grebs e483ea87cc Make sure we extract and analyze en-gb as english correctly. (#6218)
* Make sure we extract and analyze en-gb as english correctly.

Fixes #6156

* Add more tests verifying search behavior

* Actually run search from multiple locales

* Fix test settings to include en-GB and Spanish locales, use more unicode

* Fix flake8

* Fix fake language config
2017-08-23 11:06:30 +02:00
Christopher Grebs b90bf13922 Merge pull request #5791 from mozilla/1573-implement-django-jinja
Loads of clean-ups along the way.

Fixes #1573

* Moves all helpers modules to templatetags.jinja_helpers - there are a few things in there that aren't jinja related so there'll be a follow-up to split that later
* Update Jinja2 to 2.9.6
* Add django-jinja 2.3.1
* move some jingo-minify helpers to olympia.lib to avoid any jingo imports
* unified |f and |fe helpers into one |format_html helper that always escapes everything unless the input is already |safe

* Move helpers, add requirements, fix imports.
* Give backend a proper name
* Port f and fe filters from jingo
* Make start porting reviews jinja helpers module, make first test pass
* Get a handful more tests working, get rid of get_env, more and more jingo calls.
* Disable extension matching, render .txt templates too, fixes more stats tests
* Fix csv_header template to produce some reasonable and csv parsable
* Set trim_blocks to be compatible with jingo
* Unify |f and |fe into one |format that simplifies escaping rules. Update tests.

I think having one unified |format filter is beneficial, especially
given that our current escaping rules were kinda complicated and allowed
for seriously dangerous combinations even with autoescape activated.

Now everything passed as an argument to |format is explicitly escaped
unless marked as |safe, there's no way around that anymore.

* Naive first version using |format instead of |f and |fe, might need more review.
* Fix format for unicode strings
* Rename |format to |format_html
* Move nl2br_xhtml to amo.jinja_helpers, use it in all our templates.
* Move datetime filter to our code temporarily, fix mocks, fix recursive error
* Move csrf call to django_jinja csrf_token tag, fix addons templatetags
* Fix |class_selected usage, fix render_with to get registered
* Remove hack from zadmin, fix zadmin templatetags
* Fix user delete photo test, don't rely on proper context updates that happen in order.
* Fix more nl2br tests
* Fix detail page escape, django escapes differently than jinja
* Remove context from edit_review_reply_form
* Fix date created format filter usage
* Remove templates setting user, fix can_review
* Fix collect_add_widget to not inherit the global context
* Remove happy unicode client
* Cleanup can_review, add tests
* Fix tests, django use different html character for double quote escaping
* Switch to firefox latest to check ui-tests
* Cleanup and fix do_truncate
* Remove jingo, copy jingo-minify helpers that depend on jingo to our lib for now
* Rename nl2br_xhtml -> nl2br
* Jinja 2.9 compat for reviews truncate filter
* Don't use TEMPLATE_DEBUG
* Set default value for q, happens on index page.
* Fix jinja2 formatting with newstyle gettext
2017-06-30 17:57:31 -07:00
Christopher Grebs 8207e520c4 Fix tests in travis 2017-05-23 13:38:27 +07:00
Christopher Grebs aba4b7c860 Make sure dbr and dbl have plural forms defined, add test. 2017-05-23 13:22:44 +07:00
Christopher Grebs bef6e8aeae Integrate potools, add rtl support to debug (#5455)
* Integrate dbr and dbl generated with potools.

Fixes #2817

* Fix zadmin.forms, update tests to include debug languages.

* re-add extract

* Run potools via 'npm run' to avoid PATH issues

* Fix get_locale_from_lang and actually test support for debug-languages

* Fix flake8

* Update potools to 0.0.5

* Regenerate dbl and dbr locales.
2017-05-22 21:06:10 +07:00
Mathieu Pillard 2c487211d2 Remove support for MOBILE application (old Fennec) 2017-05-09 15:10:03 +02:00
Andrew Williamson 37e1df2f06 Change task user used in tests so it's not the admin user 2017-01-25 10:16:07 +00:00
Mark Striemer a207265995 Remove set_password/check_password (supports #3049) (#3662) 2016-10-13 12:37:43 -05:00
Mark Striemer 2a40fd88eb Use a test backend for client login (supports #3049) (#3656) 2016-10-12 10:52:00 -05:00
Mathieu Pillard 3763314434 Pretend our product details are always up to date in tests (#3268) 2016-08-12 15:22:05 -07:00
Mathieu Pillard 590150c7c1 Merge pull request #2902 from diox/reduce-log-verbosity-in-tests
Don't log so much stuff in the tests
2016-06-15 16:22:16 +01:00
Mathieu Pillard aad62596b6 Don't log so much stuff in the tests 2016-06-15 15:15:25 +01:00
Christopher Grebs c36308dc99 I found some unused settings in settings_test. Let's remove them. 2016-06-15 16:06:55 +02:00
Christopher Grebs 74f14b492a Remove VALIDATE_ADDONS setting.
There's no need for it anymore.
2016-03-14 17:20:16 +01:00
Christopher Grebs 5b7ae06efd Update django-piston-oauth2, fix merges, more path/import fixes.
* Make migrations work again
* Fix paths in Makefile, make sure olympia get's installed as a module too
* Fix migrations path in 'initialize_db'
* Make sure settings won't be loaded on top in olympia.startup
2016-01-06 10:48:04 +01:00
Christopher Grebs 580ccf7710 Update gitignore, updates to mock/patch import paths, minor fixes along the way. 2016-01-06 10:48:04 +01:00
Christopher Grebs c6d1cc2d66 Update django-waffle, django-piston, more import path fixes.
* Pull in django-waffle 0.10 and a fixed version of django-piston.
  Both provide late-initialization support by not calling get_user_model
  on import-time.
* Add alias for addons.buttons.js
2016-01-06 10:48:03 +01:00
Andy McKay 97f6d58ac2 Revert "update django-product-details and set to https (bug 1113852)"
This reverts commit bad516af81.
2015-12-21 13:22:01 -08:00
Andy McKay bad516af81 update django-product-details and set to https (bug 1113852) 2015-12-04 14:28:53 -08:00
Kumar McMillan fa65808a2d Revert "Use the Travis cache to dramatically speed up test dependency installation."
This reverts commit 81d6f202ee.

django-cache-machine==0.8 does not match what we were using in the git
revision beforehand. This is blocking us on master so I'm just going to revert
temporarily while we fix up pyrepo to get the right packages on there.
2015-10-19 16:32:27 -05:00
Kris Maglione 81d6f202ee Use the Travis cache to dramatically speed up test dependency installation. 2015-10-19 10:36:28 -07:00
Mathieu Agopian 0432e85450 Add the approve_addons management command (bug 1199234) 2015-09-04 10:44:04 +02:00
Kris Maglione 50f1397418 Upgrade Celery and remove some now-unnecessary cruft (fixes bug 1194181). 2015-08-27 15:14:46 -07:00
Kris Maglione edeff385b5 Use separate Elasticsearch instances and memcache pools for each slave when running under xdist. 2015-08-25 12:56:07 -07:00
Kris Maglione b6d2227748 Shuffle some test initialization code to allow running under xdist. 2015-08-25 12:56:07 -07:00
Mathieu Agopian 507ff1c46a Don't configure signing endpoints by default for tests 2015-04-20 20:51:22 +02:00
Mathieu Agopian 82786a084c But still use X-SENDFILE for tests 2015-03-07 19:48:55 +01:00