def test_filter_unknown_keyword(self, model, index):
     filterString = '(Foo < 10) and (Bar > 1)'
     search = DataSearch("Test", filterString)
     preFilterRows = model.rowCount()
     model.setFilter(search)
     postFilterRows = model.rowCount()
     assert preFilterRows == postFilterRows
示例#2
0
    def test_extentSearch(self, geoDataFrame, dataFrame):
        datasearch = DataSearch('Test', dataFrame=geoDataFrame)

        filterString = 'extentSearch(51, 9, 55, 14)'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 1

        datasearch = DataSearch('Test', dataFrame=dataFrame)

        filterString = 'extentSearch(51, 9, 55, 14)'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 0
示例#3
0
    def test_init(self, dataFrame):
        filterString = 'Foo < 10'
        datasearch = DataSearch("Test", filterString)
        assert datasearch._filterString == filterString
        assert isinstance(datasearch._dataFrame, pandas.DataFrame)
        assert datasearch.name == 'Test'

        datasearch = DataSearch("Test2")
        assert datasearch._filterString == ''
        assert isinstance(datasearch._dataFrame, pandas.DataFrame)
        assert datasearch.name == 'Test2'

        datasearch = DataSearch("Test3", dataFrame=dataFrame)
        assert datasearch._filterString == ''
        assert isinstance(datasearch._dataFrame, pandas.DataFrame)
        assert datasearch.name == 'Test3'
        assert len(datasearch._dataFrame.index) == 3
示例#4
0
    def test_setFilterString(self):
        datasearch = DataSearch("Test")
        filterString = 'foo bar'
        datasearch.setFilterString(filterString)
        assert datasearch.filterString() == filterString

        filterString = ' foo bar '
        datasearch.setFilterString(filterString)
        assert datasearch.filterString() != filterString
        assert datasearch.filterString() == filterString.strip()
示例#5
0
    def test_dataFrame(self, dataFrame):
        datasearch = DataSearch("Test")
        assert datasearch.dataFrame().empty
        assert isinstance(datasearch.dataFrame(), pandas.DataFrame)

        datasearch = DataSearch("Test", dataFrame=dataFrame)
        assert len(datasearch.dataFrame()) == 3
    def test_filter_multiColumn(self, model, index):
        filterString = '(Foo < 10) & (Bar > 1)'
        search = DataSearch("Test", filterString)
        preFilterRows = model.rowCount()
        model.setFilter(search)
        postFilterRows = model.rowCount()

        assert preFilterRows > postFilterRows
        assert preFilterRows == (postFilterRows + 2)
    def test_filter_freeSearch(self, model, index):
        filterString = 'freeSearch("10")'
        search = DataSearch("Test", filterString)
        preFilterRows = model.rowCount()
        model.setFilter(search)
        postFilterRows = model.rowCount()

        assert preFilterRows > postFilterRows
        assert preFilterRows == (postFilterRows + 2)
    def test_filter_single_column(self, model, index):
        filterString = 'Foo < 10'
        search = DataSearch("Test", filterString)
        preFilterRows = model.rowCount()
        model.setFilter(search)
        postFilterRows = model.rowCount()

        assert preFilterRows > postFilterRows
        assert preFilterRows == (postFilterRows + 1)
示例#9
0
    def test_search(self, dataFrame):
        datasearch = DataSearch('Test', dataFrame=dataFrame)

        filterString = 'Foo < 10'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 2

        filterString = 'Foo < 10 and Bar'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert not valid

        filterString = '(Foo < 10) & (Bar > 1)'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 1

        filterString = '(Monty < 10) & (Bar > 1)'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert not valid
示例#10
0
 def test_filterString(self):
     datasearch = DataSearch("Test")
     assert datasearch.filterString() == ''
     datasearch = DataSearch('Test2', filterString='Hello World')
     assert datasearch.filterString() == 'Hello World'
示例#11
0
 def test_repr(self, dataFrame):
     datasearch = DataSearch("Test2")
     assert str(datasearch).startswith('DataSearch(')
     assert str(datasearch).endswith('Test2 ()')
示例#12
0
    def test_indexSearch(self, dataFrame):
        datasearch = DataSearch('Test', dataFrame=dataFrame)

        filterString = 'indexSearch([0])'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 1

        filterString = 'indexSearch([0, 2])'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 2

        filterString = 'indexSearch([0, 1, 2])'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 3

        filterString = 'indexSearch([99])'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 0
示例#13
0
    def test_freeSearch(self, dataFrame):
        datasearch = DataSearch('Test', dataFrame=dataFrame)

        filterString = 'freeSearch("0")'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 2

        filterString = 'freeSearch(1)'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert not valid

        filterString = 'freeSearch("12")'
        datasearch.setFilterString(filterString)
        ret, valid = datasearch.search()
        assert valid
        assert sum(ret) == 1
示例#14
0
 def setFilter(self):
     #filterIndex = eval(self.lineEditFilterCondition.text())
     search = DataSearch("Test", self.lineEditFilterCondition.text())
     self.dataTableView.view().model().setFilter(search)