2
from twisted.trial.unittest import TestCase
4
from axiom.store import Store
5
from axiom.item import Item
6
from axiom.attributes import reference, text, bytes, AND
13
type = text(indexed=True)
21
name = text(indexed=True)
27
name = text(indexed=True)
29
class ThingWithCharacterAndByteStrings(Item):
32
typeName = 'ThingWithCharacterAndByteStrings'
34
characterString = text(caseSensitive=True)
35
caseInsensitiveCharString = text(caseSensitive=False)
40
class BasicQuery(TestCase):
42
def testBasicQuery(self):
75
AND(AND(C.name == u'yes',
77
AND(C.storeID == B.cref,
78
A.reftoc == C.storeID)),
81
self.assertEquals(q, [yesb])
87
def testStringQueries(self):
91
text1 = u'Hello, \u1234 world.'
92
text2 = u'ThIs sTrInG iS nOt cAsE sEnSiTIvE. \u4567'
95
x = ThingWithCharacterAndByteStrings(
97
characterString=text1,
98
caseInsensitiveCharString=text2,
104
s.query(ThingWithCharacterAndByteStrings,
105
ThingWithCharacterAndByteStrings.characterString == text1.lower(),
110
s.query(ThingWithCharacterAndByteStrings,
111
ThingWithCharacterAndByteStrings.characterString == text1.upper(),
116
s.query(ThingWithCharacterAndByteStrings,
117
ThingWithCharacterAndByteStrings.characterString == text1,
120
self.assertEquals(q, [x])
123
s.query(ThingWithCharacterAndByteStrings,
124
ThingWithCharacterAndByteStrings.caseInsensitiveCharString == text2,
127
self.assertEquals(q, [x])
130
s.query(ThingWithCharacterAndByteStrings,
131
ThingWithCharacterAndByteStrings.caseInsensitiveCharString == text2.lower(),
134
self.assertEquals(q, [x])
137
s.query(ThingWithCharacterAndByteStrings,
138
ThingWithCharacterAndByteStrings.caseInsensitiveCharString == text2.upper(),
141
self.assertEquals(q, [x])
144
s.query(ThingWithCharacterAndByteStrings,
145
ThingWithCharacterAndByteStrings.byteString == bytes1,
148
self.assertEquals(q, [x])
151
s.query(ThingWithCharacterAndByteStrings,
152
ThingWithCharacterAndByteStrings.byteString == bytes1.upper(),
157
s.transact(createAndStuff)