mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 02:26:53 -07:00
Move common libs to libs/common
This commit is contained in:
parent
8dbb1a2451
commit
1f4bd41bcc
1612 changed files with 962 additions and 10 deletions
64
libs/common/rebulk/test/test_validators.py
Normal file
64
libs/common/rebulk/test/test_validators.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# pylint: disable=no-self-use, pointless-statement, missing-docstring, invalid-name,len-as-condition
|
||||
|
||||
from functools import partial
|
||||
|
||||
from rebulk.pattern import StringPattern
|
||||
|
||||
from ..validators import chars_before, chars_after, chars_surround, validators
|
||||
|
||||
chars = ' _.'
|
||||
left = partial(chars_before, chars)
|
||||
right = partial(chars_after, chars)
|
||||
surrounding = partial(chars_surround, chars)
|
||||
|
||||
|
||||
def test_left_chars():
|
||||
matches = list(StringPattern("word", validator=left).matches("xxxwordxxx"))
|
||||
assert len(matches) == 0
|
||||
|
||||
matches = list(StringPattern("word", validator=left).matches("xxx_wordxxx"))
|
||||
assert len(matches) == 1
|
||||
|
||||
matches = list(StringPattern("word", validator=left).matches("wordxxx"))
|
||||
assert len(matches) == 1
|
||||
|
||||
|
||||
def test_right_chars():
|
||||
matches = list(StringPattern("word", validator=right).matches("xxxwordxxx"))
|
||||
assert len(matches) == 0
|
||||
|
||||
matches = list(StringPattern("word", validator=right).matches("xxxword.xxx"))
|
||||
assert len(matches) == 1
|
||||
|
||||
matches = list(StringPattern("word", validator=right).matches("xxxword"))
|
||||
assert len(matches) == 1
|
||||
|
||||
|
||||
def test_surrounding_chars():
|
||||
matches = list(StringPattern("word", validator=surrounding).matches("xxxword xxx"))
|
||||
assert len(matches) == 0
|
||||
|
||||
matches = list(StringPattern("word", validator=surrounding).matches("xxx.wordxxx"))
|
||||
assert len(matches) == 0
|
||||
|
||||
matches = list(StringPattern("word", validator=surrounding).matches("xxx word_xxx"))
|
||||
assert len(matches) == 1
|
||||
|
||||
matches = list(StringPattern("word", validator=surrounding).matches("word"))
|
||||
assert len(matches) == 1
|
||||
|
||||
|
||||
def test_chain():
|
||||
matches = list(StringPattern("word", validator=validators(left, right)).matches("xxxword xxx"))
|
||||
assert len(matches) == 0
|
||||
|
||||
matches = list(StringPattern("word", validator=validators(left, right)).matches("xxx.wordxxx"))
|
||||
assert len(matches) == 0
|
||||
|
||||
matches = list(StringPattern("word", validator=validators(left, right)).matches("xxx word_xxx"))
|
||||
assert len(matches) == 1
|
||||
|
||||
matches = list(StringPattern("word", validator=validators(left, right)).matches("word"))
|
||||
assert len(matches) == 1
|
Loading…
Add table
Add a link
Reference in a new issue