Skip to content

Commit cfd3ddc

Browse files
committed
test cqlengine.Columns comparison
PYTHON-595
1 parent bca0cee commit cfd3ddc

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

tests/unit/cqlengine/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2013-2016 DataStax, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright 2013-2016 DataStax, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
try:
16+
import unittest2 as unittest
17+
except ImportError:
18+
import unittest # noqa
19+
20+
from cassandra.cqlengine.columns import Column
21+
22+
23+
class ColumnTest(unittest.TestCase):
24+
25+
def test_comparisons(self):
26+
c0 = Column()
27+
c1 = Column()
28+
self.assertEqual(c1.position - c0.position, 1)
29+
30+
# __ne__
31+
self.assertNotEqual(c0, c1)
32+
self.assertNotEqual(c0, object())
33+
34+
# __eq__
35+
self.assertEqual(c0, c0)
36+
self.assertFalse(c0 == object())
37+
38+
# __lt__
39+
self.assertLess(c0, c1)
40+
try:
41+
c0 < object() # this raises for Python 3
42+
except TypeError:
43+
pass
44+
45+
# __le__
46+
self.assertLessEqual(c0, c1)
47+
self.assertLessEqual(c0, c0)
48+
try:
49+
c0 <= object() # this raises for Python 3
50+
except TypeError:
51+
pass
52+
53+
# __gt__
54+
self.assertGreater(c1, c0)
55+
try:
56+
c1 > object() # this raises for Python 3
57+
except TypeError:
58+
pass
59+
60+
# __ge__
61+
self.assertGreaterEqual(c1, c0)
62+
self.assertGreaterEqual(c1, c1)
63+
try:
64+
c1 >= object() # this raises for Python 3
65+
except TypeError:
66+
pass
67+
68+

0 commit comments

Comments
 (0)