def _testInFilterWithAdditionalLookup(self, a, b, g): aTableCursor = aFilterCursor(self.context) bTableCursor = bFilterCursor(self.context) gTableCursor = gFilterCursor(self.context) aTableCursor.deleteAll() bTableCursor.deleteAll() gTableCursor.deleteAll() timestamp = Timestamp.valueOf(LocalDateTime.now()) self._fillTablesForTestInFilterWithRangeOnOtherCursor(aTableCursor, bTableCursor, timestamp) gTableCursor.createDate = timestamp gTableCursor.num1 = 5 gTableCursor.num2 = -30 gTableCursor.insert() gTableCursor.clear() gTableCursor.createDate = timestamp gTableCursor.num1 = 6 gTableCursor.num2 = -40 gTableCursor.insert() gTableCursor.clear() gTableCursor.createDate = timestamp gTableCursor.num1 = 1 gTableCursor.num2 = -41 gTableCursor.insert() gTableCursor.clear() gTableCursor.createDate = timestamp gTableCursor.num1 = 1 gTableCursor.num2 = -42 gTableCursor.insert() gTableCursor.clear() lookup = a.setIn(b).add("date", "created").add("number1", "numb1") additionalLookup = lookup.and(g).add("date", "createDate").add("number1", "num1") self.assertEquals(3, a.count()) b.setRange('numb2', -40) self.assertEquals(2, a.count()) a.first() self.assertEquals(5, a.number1) self.assertEquals(-10, a.number2) a.navigate('>') self.assertEquals(6, a.number1) self.assertEquals(-20, a.number2) g.setRange('num2', -30) self.assertEquals(1, a.count()) a.first() self.assertEquals(5, a.number1) self.assertEquals(-10, a.number2)
def _testInFilterWithRangeInOtherCursorAfterSetIn(self, a, b): aTableCursor = aFilterCursor(self.context) bTableCursor = bFilterCursor(self.context) aTableCursor.deleteAll() bTableCursor.deleteAll() timestamp = Timestamp.valueOf(LocalDateTime.now()) self._fillTablesForTestInFilterWithRangeOnOtherCursor(aTableCursor, bTableCursor, timestamp) lookup = a.setIn(b).add("date", "created").add("number1", "numb1") self.assertEquals(3, a.count()) b.setRange('numb2', -40) self.assertEquals(2, a.count()) a.first() self.assertEquals(5, a.number1) self.assertEquals(-10, a.number2) a.navigate('>') self.assertEquals(6, a.number1) self.assertEquals(-20, a.number2)
def testExceptionWhileAddingFieldsWithoutIndexToLookup(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) lookup = a.setIn(b) lookupAdd = lambda targetCol, auxiliaryCol : lookup.add(targetCol, auxiliaryCol) self.assertThrows(CelestaException, lookupAdd, "noIndexA", "numb1") self.assertThrows(CelestaException, lookupAdd, "number1", "noIndexB") self.assertThrows(CelestaException, lookupAdd, "noIndexA", "noIndexB")
def testExceptionWhenPairsFromLookupDoNotMatchToIndices(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) lookup = a.setIn(b) lookupAdd = lambda targetCol, auxiliaryCol : lookup.add(targetCol, auxiliaryCol) self.assertThrows(CelestaException, lookupAdd, "number1", "numb2") self.assertThrows(CelestaException, lookupAdd, "number2", "numb1") lookupDoubleAdd = lambda targetCol1, auxiliaryCol1, targetCol2, auxiliaryCol2 : \ lookup.add(targetCol1, auxiliaryCol1).add(targetCol2, auxiliaryCol2) self.assertThrows(CelestaException, lookupDoubleAdd, "date", "created", "number2", "numb2")
def _testInFilterForIndices(self, a, b): aTableCursor = aFilterCursor(self.context) bTableCursor = bFilterCursor(self.context) aTableCursor.deleteAll() bTableCursor.deleteAll() timestamp = Timestamp.valueOf(LocalDateTime.now()) aTableCursor.date = timestamp aTableCursor.number1 = 5 aTableCursor.number2 = -10 aTableCursor.insert() aTableCursor.clear() aTableCursor.date = timestamp aTableCursor.number1 = 1 aTableCursor.number2 = -20 aTableCursor.insert() aTableCursor.clear() aTableCursor.date = Timestamp.valueOf(LocalDateTime.now().plusDays(1)) aTableCursor.number2 = -30 aTableCursor.insert() aTableCursor.clear() bTableCursor.created = timestamp bTableCursor.numb1 = 2 bTableCursor.numb2 = -40 bTableCursor.insert() bTableCursor.clear() bTableCursor.created = timestamp bTableCursor.numb1 = 5 bTableCursor.numb2 = -50 bTableCursor.insert() bTableCursor.clear() lookup = a.setIn(b).add("date", "created") self.assertEquals(2, a.count()) lookup = a.setIn(b).add("date", "created").add("number1", "numb1") self.assertEquals(1, a.count()) a.setIn(b).add("date", "created").add("number1", "numb1").add("number2", "numb2") self.assertEquals(0, a.count())
def _testInFilterWithRangeInMainCursor(self, a, b): aTableCursor = aFilterCursor(self.context) bTableCursor = bFilterCursor(self.context) aTableCursor.deleteAll() bTableCursor.deleteAll() timestamp = Timestamp.valueOf(LocalDateTime.now()) aTableCursor.date = timestamp aTableCursor.number1 = 5 aTableCursor.number2 = -10 aTableCursor.insert() aTableCursor.clear() aTableCursor.date = timestamp aTableCursor.number1 = 1 aTableCursor.number2 = -20 aTableCursor.insert() aTableCursor.clear() aTableCursor.date = Timestamp.valueOf(LocalDateTime.now().plusDays(1)) aTableCursor.number2 = -30 aTableCursor.insert() aTableCursor.clear() bTableCursor.created = timestamp bTableCursor.numb1 = 2 bTableCursor.numb2 = -40 bTableCursor.insert() bTableCursor.clear() bTableCursor.created = timestamp bTableCursor.numb1 = 5 bTableCursor.numb2 = -50 bTableCursor.insert() bTableCursor.clear() a.setRange('number1', 5) lookup = a.setIn(b).add("date", "created") self.assertEquals(1, a.count()) a.first()
def testInFilterWithRangeInOtherCursorBeforeSetInForTable(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) self._testInFilterWithRangeInOtherCursorBeforeSetIn(a, b)
def testInFilterWithRangeInMainCursorForTable(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) self._testInFilterWithRangeInMainCursor(a, b)
def testExceptionWhileAddingFieldsWithNotMatchesTypesToLookupForTable(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) self._testExceptionWhileAddingFieldsWithNotMatchesTypesToLookup(a, b)
def testExceptionWhileAddingNotExistedFieldsToLookupForTable(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) self._testExceptionWhileAddingNotExistedFieldsToLookup(a, b)
def testInFilterForTable(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) self._testInFilterForIndices(a, b)
def testInFilterWithAdditionalLookupForTable(self): a = aFilterCursor(self.context) b = bFilterCursor(self.context) g = gFilterCursor(self.context) self._testInFilterWithAdditionalLookup(a, b, g)