|
|
Mads Kiilerich
|
5e46f73f0d1c
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
b095e2fbba44
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
e35373106528
|
6 years ago
|
|
py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings
(The remaining safe_unicode calls are still needed and can't just be removed, generally because we in these cases still have to convert from bytes to unicode strings.)
|
|
|
Mads Kiilerich
|
756e46bd926b
|
6 years ago
|
|
py3: trivial renaming of .iteritems() to .items()
A bit like "2to3 -f dict", but we don't want list().
|
|
|
Mads Kiilerich
|
e527cc2ce8dc
|
6 years ago
|
|
cleanup: get rid of most "import *"
Apply script generated with the following hack: ( hg loc '*.py'|xargs pyflakes-2 | sed -rn "s/([^:]*):.*'(.*)' may be undefined, or defined from star imports.*/sed -ri 's,\\\\<\2\\\\>([^=]|$),XXXX.\2\\\\1,g' \1/gp" | sort -u hg loc '*.py'|xargs pyflakes-2 | sed -rn "s/([^:]*):.* undefined name '(.*)'$/sed -ri 's,\\\\<\2\\\\>([^=]|$),XXXX.\2\\\\1,g' \1/gp" | sort -u hg loc '*.py'|xargs pyflakes-2 | sed -rn "s/([^:]*):.*'(from .*)\.([^.]*) import \*' used.*/sed -ri 's,\\\\<XXXX\\\\.,\3.,g' \1/gp" | sort -u hg loc '*.py'|xargs pyflakes-2 | sed -rn "s/([^:]*):.*'(from .*)\.([^.]*) import \*' used.*/sed -ri 's,\2\\\\.\3 .*,\2 import \3,g' \1/gp" | sort -u ) | grep -v kallithea/bin/kallithea_cli_ishell.py > fix2.sh
|
|
|
Mads Kiilerich
|
0a277465fddf
|
6 years ago
|
|
|
|
|
FUJIWARA Katsunori
|
2ff913970025
|
9 years ago
|
|
journal: make "username:" filtering condition work as expected
As described in previous revision, using TEXT in JOURNAL_SCHEMA causes unexpected results for "username:", too.
- tokenization by non-alphanumeric characters - removing "stop words"
To make "username:" filtering condition work as expected, this revision uses ID instead of TEST for "username" of JOURNAL_COLUMN.
|
|
|
FUJIWARA Katsunori
|
73e3599971da
|
9 years ago
|
|
journal: make "repository:" filtering condition work as expected (Issue #261)
Before this revision, journal filtering conditions like as below never match against any entry, even if there are corresponded repositories.
- repository:foo/bar - repository:foo-bar
Whoosh library, which is used to parse filtering condition, does:
- treat almost all non-alphanumeric characters as delimiter at parsing condition - join each conditions at filtering by "AND", by default
For example, filtering condition "repository:foo/bar" is translated as "repository:foo AND repository:bar". This combined condition never matches against any entry, because it is impossible that "repository" field in DBMS table "user_logs" has both "foo" and "bar" values at same time.
Using TEXT for "repository" of JOURNAL_SCHEMA causes this issue, because TEXT assumes tokenization at parsing.
In addition to it, using TEXT also causes unintentional ignorance of "stop words" in filtering conditions. For example, "this", "a", "you", and so on are ignored at parsing, because these are too generic words (from point of view of generic "text search").
To make "repository:" filtering condition work as expected, this revision uses ID instead of TEST for "repository" of JOURNAL_COLUMN. ID avoids both tokenization and removing "stop words".
This replacement should be safe with already existing DBMS instance, because:
- JOURNAL_SCHEMA is used only to parse filtering condition - DBMS table "user_logs" itself is defined by UserLog class (in kallithea/model/db.py)
BTW, using ID also avoids normalization by lowercase-ing. But this doesn't violate current case-insensitive search policy, because LOWER-ing in actual SQL query is achieved by get_filterion() or so in kallithea/controllers/admin/admin.py.
|
|
|
FUJIWARA Katsunori
|
e6224a7c3d4e
|
9 years ago
|
|
tests: introduce more test coverage of whoosh filtering
This has been extracted from other changesets by Mads Kiilerich to establish a test baseline so we clearly can see what the following fixes are fixing.
Some of these tests will thus demonstrate bad behaviour - that will be fixed later.
|
|
|
Thomas De Schampheleire
|
8d98924c58b1
|
9 years ago
|
|
tests: add as little code as possible in __init__.py
kallithea/tests/__init__.py contained quite a lot of code, including the test base class TestController. This in itself may be considered bad practice.
Specifically, this poses a problem when using pytest 3.0+, in which asserts in some files are not automatically rewritten to give improved assert output. That problem can be fixed by explicitly registering such files for assertion rewriting, but that register call should be executed _before_ said files are imported. I.e. if the register call is in kallithea/tests/__init__.py, assert calls in __init__.py itself can not be rewritten.
Since the TestController base class does effectively contain asserts, and we do not want to execute the register call from somewhere outside the kallithea/tests directory, we need to move the TestController class to another file (kallithea/tests/base.py) so we can have a register call in __init__.py before loading base.py.
While not strictly necessary to fix the mentioned pytest problem, we take the opportunity to fully clean __init__.py and move everything to the new kallithea/tests/base.py. While doing so, unnecessary imports are removed, and imports are ordered alphabetically. Explicit imports of symbols from modules that were already imported as a whole, are removed in favor of fully qualifying the references (e.g. tempfile._RandomNameSequence).
|
|
|
domruf
|
037efd94e955
|
9 years ago
|
|
cleanup: get rid of dn as shortcut for os.path.dirname
We keep 'dirname' as shortcut despite having removed the 'join' shortcut: * the name is less ambiguous than 'join'. * dirname is often applied multiple times - spelling it out would be too verbose.
|
|
|
Thomas De Schampheleire
|
7f2aa3ec2931
|
10 years ago
|
|
pytest migration: rename TestControllerPytest back to TestController
The name TestControllerPytest was introduced to allow a temporary situation where nose/unittest and pytest-based tests could coexist. This situation is now over, so the base test class can be renamed again.
|
|
|
Thomas De Schampheleire
|
15c40f8a3510
|
10 years ago
|
|
pytest migration: convert functional tests with setup/teardown methods
pytest also supports setup/teardown methods like unittest (even though pytest fixtures are more powerful and should be the end goal). Only difference is the naming and signature of setUp (setup_method) and tearDown (teardown_method).
|
|
|
Søren Løvborg
|
431689d7f37d
|
10 years ago
|
|
remove vestiges of Python 2.5 support
We only support Python 2.6 and 2.7; hence we do not need to import with-statement support from __future__.
|
|
|
Mads Kiilerich
|
91fd320663ce
|
11 years ago
|
|
|
|
|
Na'Tosha Bard
|
dacdea9fda2a
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
703d3208424c
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
d1addaf7a91e
|
11 years ago
|
|
Second step in two-part process to rename directories. This is the actual directory rename.
|