Example #1
0
    def test_equality(self):
        ''' Test basic equality comparison for `util.struct.Sentinel`. '''

        SAMPLE = struct.Sentinel('SAMPLE')
        assert SAMPLE.name == "SAMPLE"

        SAMPLE2 = struct.Sentinel('SAMPLE')
        assert SAMPLE == SAMPLE2
Example #2
0
'''

__version__ = 'v3'

# stdlib
import abc
import operator

# canteen utils
from canteen.util import struct as datastructures

## Globals / Constants

# Filter components
_TARGET_KEY = datastructures.Sentinel('KEY')
PROPERTY = datastructures.Sentinel('PROPERTY')
KEY_KIND = datastructures.Sentinel('KEY_KIND')
KEY_ANCESTOR = datastructures.Sentinel('KEY_ANCESTOR')

# Sort directions
ASCENDING = ASC = datastructures.Sentinel('ASCENDING')
DESCENDING = DSC = datastructures.Sentinel('DESCENDING')

# Query operators
EQUALS = EQ = datastructures.Sentinel('EQUALS')
NOT_EQUALS = NE = datastructures.Sentinel('NOT_EQUALS')
LESS_THAN = LT = datastructures.Sentinel('LESS_THAN')
LESS_THAN_EQUAL_TO = LE = datastructures.Sentinel('LESS_THAN_EQUAL_TO')
GREATER_THAN = GT = datastructures.Sentinel('GREATER_THAN')
GREATER_THAN_EQUAL_TO = GE = datastructures.Sentinel('GREATER_THAN_EQUAL_TO')
Example #3
0
    def test_not_falsy(self):
        ''' Test ability to set a Sentinel as truthy. '''

        GOOD = struct.Sentinel('GOOD', falsy=False)
        assert GOOD
Example #4
0
    def test_falsy(self):
        ''' Test ability to set a Sentinel as falsy. '''

        BAD = struct.Sentinel('BAD', falsy=True)
        assert not BAD
Example #5
0
    def test_repr(self):
        ''' Test basic string representation of a `util.struct.Sentinel`. '''

        SAMPLE = struct.Sentinel('SAMPLE')
        assert 'SAMPLE' in str(SAMPLE)
Example #6
0
    def test_construct(self):
        ''' Test basic functionality of `util.struct.Sentinel`. '''

        SAMPLE = struct.Sentinel('SAMPLE')
        assert SAMPLE.name == "SAMPLE"