示例#1
0
    def test_get_rows_dict_multiple_rows_index_error(self):
        """ get_row_dict raises IndexError when wrong index used. """
        self.init_itertable(columnDesc=["c1", "c2"],
                            start=0,
                            numPageRows=1,
                            numRows=20,
                            pageSize=10)
        self.itertable_update()
        self.pagetable_mock.getRow.side_effect = Registry.Table.INVALID_ROW

        table = IterTable('test_req_object',
                          test_corba_session_string,
                          pagesize=10)
        table.get_rows_dict(start=21, limit=100)
示例#2
0
    def test_get_rows_dict_multiple_rows(self):
        """ get_rows_dict returns multiple rows correctly. """
        self.init_itertable(self.pagetable_mock,
                            columnDesc=["c1", "c2"],
                            start=0,
                            numPageRows=1,
                            numRows=20,
                            pageSize=10)
        self.pagetable_mock._set_pageSize(11)
        self.itertable_update(self.pagetable_mock)
        for i in range(5, 16):
            self.pagetable_mock.getRow(i).AndReturn([
                CORBA.Any(CORBA.TC_string, 'test value %i.1' % i),
                CORBA.Any(CORBA.TC_string, 'test value %i.2' % i)
            ])
            self.pagetable_mock.getRowId(i).AndReturn(i)
        self.corba_mock.ReplayAll()

        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=10)
        rows = table.get_rows_dict(start=5, limit=11)

        assert len(rows) == 11
        assert len(rows[6]) == 3
        assert rows[6].get(u'Id') == u'11'
        assert rows[6].get(u'c1') == u'test value 11.1'
        assert rows[6].get(u'c2') == u'test value 11.2'
示例#3
0
    def test_get_rows_dict(self):
        """ get_rows_dict returns correct rows when no arguments are given. """
        self.init_itertable(columnDesc=["c1", "c2"],
                            page=1,
                            pageSize=2,
                            start=5,
                            numRows=10,
                            numPageRows=2)
        self.pagetable_mock.getRow.side_effect = lambda row_num: \
            {5: [CORBA.Any(CORBA.TC_string, 'test value 1.1'),
                 CORBA.Any(CORBA.TC_string, 'test value 1.2')],
             6: [CORBA.Any(CORBA.TC_string, 'test value 2.1'),
                 CORBA.Any(CORBA.TC_string, 'test value 2.2')],
            }[row_num]
        self.pagetable_mock.getRowId.side_effect = lambda row_num: row_num

        table = IterTable('test_req_object',
                          test_corba_session_string,
                          pagesize=2)
        rows = table.get_rows_dict()

        assert_equal(len(rows), 2)

        assert_equal(len(rows[0]), 3)
        assert_equal(rows[0].get(u'Id'), u'5')
        assert_equal(rows[0].get(u'c1'), u'test value 1.1')
        assert_equal(rows[0].get(u'c2'), u'test value 1.2')

        assert_equal(len(rows[1]), 3)
        assert_equal(rows[1].get(u'Id'), u'6')
        assert_equal(rows[1].get(u'c1'), u'test value 2.1')
        assert_equal(rows[1].get(u'c2'), u'test value 2.2')
示例#4
0
    def test_get_rows_dict(self):
        """ get_rows_dict returns correct rows when no arguments are given. """
        self.init_itertable(
            self.pagetable_mock, columnDesc=["c1", "c2"], page=1, pageSize=2, 
            start=5, numRows=10, numPageRows=2)
        self.pagetable_mock.getRow(5).AndReturn(
            [CORBA.Any(CORBA.TC_string, 'test value 1.1'), 
             CORBA.Any(CORBA.TC_string, 'test value 1.2')])
        self.pagetable_mock.getRowId(5).AndReturn(5)
        self.pagetable_mock.getRow(6).AndReturn(
            [CORBA.Any(CORBA.TC_string, 'test value 2.1'), 
             CORBA.Any(CORBA.TC_string, 'test value 2.2')])
        self.pagetable_mock.getRowId(6).AndReturn(6)
        self.corba_mock.ReplayAll()

        table = IterTable(
            "test_req_object", test_corba_session_string, pagesize=2)
        rows = table.get_rows_dict()

        assert len(rows) == 2

        assert len(rows[0]) == 3
        assert rows[0].get(u'Id') == u'5'
        assert rows[0].get(u'c1') == u'test value 1.1'
        assert rows[0].get(u'c2') == u'test value 1.2'

        assert len(rows[1]) == 3
        assert rows[1].get(u'Id') == u'6'
        assert rows[1].get(u'c1') == u'test value 2.1'
        assert rows[1].get(u'c2') == u'test value 2.2'

        self.corba_mock.VerifyAll()
示例#5
0
    def test_get_rows_dict_multiple_rows(self):
        """ get_row_dict returns multiple rows correctly. """
        self.init_itertable(self.pagetable_mock, columnDesc=["c1", "c2"], 
                            start=0, numPageRows=1, numRows=20, pageSize=10)
        self.pagetable_mock._set_pageSize(100)
        self.itertable_update(self.pagetable_mock)
        self.pagetable_mock.getRow(21).AndRaise(Registry.Table.INVALID_ROW)
        self.corba_mock.ReplayAll()

        table = IterTable(
            "test_req_object", test_corba_session_string, pagesize=10)
        rows = table.get_rows_dict(start=21, limit=100)
示例#6
0
    def test_get_rows_dict_multiple_rows(self):
        """ get_row_dict returns multiple rows correctly. """
        self.init_itertable(self.pagetable_mock,
                            columnDesc=["c1", "c2"],
                            start=0,
                            numPageRows=1,
                            numRows=20,
                            pageSize=10)
        self.pagetable_mock._set_pageSize(100)
        self.itertable_update(self.pagetable_mock)
        self.pagetable_mock.getRow(21).AndRaise(Registry.Table.INVALID_ROW)
        self.corba_mock.ReplayAll()

        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=10)
        rows = table.get_rows_dict(start=21, limit=100)
示例#7
0
    def test_get_rows_dict(self):
        """ get_rows_dict returns correct rows when no arguments are given. """
        self.init_itertable(self.pagetable_mock,
                            columnDesc=["c1", "c2"],
                            page=1,
                            pageSize=2,
                            start=5,
                            numRows=10,
                            numPageRows=2)
        self.pagetable_mock.getRow(5).AndReturn([
            CORBA.Any(CORBA.TC_string, 'test value 1.1'),
            CORBA.Any(CORBA.TC_string, 'test value 1.2')
        ])
        self.pagetable_mock.getRowId(5).AndReturn(5)
        self.pagetable_mock.getRow(6).AndReturn([
            CORBA.Any(CORBA.TC_string, 'test value 2.1'),
            CORBA.Any(CORBA.TC_string, 'test value 2.2')
        ])
        self.pagetable_mock.getRowId(6).AndReturn(6)
        self.corba_mock.ReplayAll()

        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=2)
        rows = table.get_rows_dict()

        assert len(rows) == 2

        assert len(rows[0]) == 3
        assert rows[0].get(u'Id') == u'5'
        assert rows[0].get(u'c1') == u'test value 1.1'
        assert rows[0].get(u'c2') == u'test value 1.2'

        assert len(rows[1]) == 3
        assert rows[1].get(u'Id') == u'6'
        assert rows[1].get(u'c1') == u'test value 2.1'
        assert rows[1].get(u'c2') == u'test value 2.2'

        self.corba_mock.VerifyAll()
示例#8
0
    def test_get_rows_dict_multiple_rows(self):
        """ get_rows_dict returns multiple rows correctly. """
        self.init_itertable(self.pagetable_mock, columnDesc=["c1", "c2"], 
                            start=0, numPageRows=1, numRows=20, pageSize=10)
        self.pagetable_mock._set_pageSize(11)
        self.itertable_update(self.pagetable_mock)
        for i in range(5, 16):
            self.pagetable_mock.getRow(i).AndReturn(
                [CORBA.Any(CORBA.TC_string, 'test value %i.1' % i), 
                 CORBA.Any(CORBA.TC_string, 'test value %i.2' % i)])
            self.pagetable_mock.getRowId(i).AndReturn(i)
        self.corba_mock.ReplayAll()

        table = IterTable(
            "test_req_object", test_corba_session_string, pagesize=10)
        rows = table.get_rows_dict(start=5, limit=11)

        assert len(rows) == 11
        assert len(rows[6]) == 3
        assert rows[6].get(u'Id') == u'11'
        assert rows[6].get(u'c1') == u'test value 11.1'
        assert rows[6].get(u'c2') == u'test value 11.2'
示例#9
0
    def test_get_rows_dict_multiple_rows(self):
        """ get_rows_dict returns multiple rows correctly. """
        self.init_itertable(columnDesc=["c1", "c2"],
                            start=0,
                            numPageRows=1,
                            numRows=20,
                            pageSize=10)

        self.pagetable_mock.getRow.side_effect = lambda row_num: \
                [CORBA.Any(CORBA.TC_string, 'test value %i.1' % row_num),
                 CORBA.Any(CORBA.TC_string, 'test value %i.2' % row_num)]
        self.pagetable_mock.getRowId.side_effect = lambda row_num: row_num

        table = IterTable('test_req_object',
                          test_corba_session_string,
                          pagesize=10)
        rows = table.get_rows_dict(start=5, limit=11)

        assert_equal(len(rows), 11)
        assert_equal(len(rows[6]), 3)
        assert_equal(rows[6].get(u'Id'), u'11')
        assert_equal(rows[6].get(u'c1'), u'test value 11.1')
        assert_equal(rows[6].get(u'c2'), u'test value 11.2')