Exemplo n.º 1
0
    def test__get_row_out_of_index(self):
        """ _get_row raises IndexError when index is out of range. """
        self.init_itertable(numPageRows=1, pageSize=50)

        self.pagetable_mock.getRow.side_effect = Registry.Table.INVALID_ROW

        table = IterTable('test_req_object',
                          test_corba_session_string,
                          pagesize=50)
        table._get_row(2)
Exemplo n.º 2
0
    def test__get_row_invalid_argument(self):
        """ _get_row fails when index is not an integer. """
        self.init_itertable(numPageRows=1, pageSize=50)

        # simulate that getRow was called with bad argument like string instead int:
        self.pagetable_mock.getRow.side_effect = \
            CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)

        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=50)
        table._get_row("intentional error - this should be an integer")
Exemplo n.º 3
0
    def test__get_row_out_of_index(self):
        """ _get_row raises IndexError when index is out of range. """
        self.init_itertable(self.pagetable_mock, numPageRows=1, pageSize=50)

        self.pagetable_mock.getRow(-1).AndRaise(
            CORBA.BAD_PARAM(omniORB.BAD_PARAM_PythonValueOutOfRange, 
                            CORBA.COMPLETED_NO))
        self.pagetable_mock.getRowId(-2).AndReturn(1)

        self.corba_mock.ReplayAll()
        table = IterTable("test_req_object", test_corba_session_string, pagesize=50)
        table._get_row(-1)
        self.corba_mock.VerifyAll()
Exemplo n.º 4
0
    def test__get_row_out_of_index(self):
        """ _get_row raises IndexError when index is out of range. """
        self.init_itertable(self.pagetable_mock, numPageRows=1, pageSize=50)

        self.pagetable_mock.getRow(-1).AndRaise(
            CORBA.BAD_PARAM(omniORB.BAD_PARAM_PythonValueOutOfRange,
                            CORBA.COMPLETED_NO))
        self.pagetable_mock.getRowId(-2).AndReturn(1)

        self.corba_mock.ReplayAll()
        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=50)
        table._get_row(-1)
        self.corba_mock.VerifyAll()
Exemplo n.º 5
0
    def test__get_row_invalid_argument(self):
        """ _get_row raises ValueError when index is not an integer. """
        self.init_itertable(self.pagetable_mock, numPageRows=1, pageSize=50)

        self.pagetable_mock.getRow(
            "intentional error - this should be an integer").AndRaise(
            CORBA.BAD_PARAM(
                omniORB.BAD_PARAM_WrongPythonType,CORBA.COMPLETED_NO))
        self.pagetable_mock.getRowId(2).AndReturn(1)

        self.corba_mock.ReplayAll()
        table = IterTable(
            "test_req_object", test_corba_session_string, pagesize=50)
        table._get_row("intentional error - this should be an integer")
        self.corba_mock.VerifyAll()
Exemplo n.º 6
0
    def test__get_row_invalid_argument(self):
        """ _get_row raises ValueError when index is not an integer. """
        self.init_itertable(self.pagetable_mock, numPageRows=1, pageSize=50)

        self.pagetable_mock.getRow(
            "intentional error - this should be an integer").AndRaise(
                CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType,
                                CORBA.COMPLETED_NO))
        self.pagetable_mock.getRowId(2).AndReturn(1)

        self.corba_mock.ReplayAll()
        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=50)
        table._get_row("intentional error - this should be an integer")
        self.corba_mock.VerifyAll()
Exemplo n.º 7
0
    def test__get_row(self):
        """_get_row returns row correctly. """
        self.init_itertable(self.pagetable_mock, pageSize=50)
        self.pagetable_mock.getRow(2).AndReturn([CORBA.Any(CORBA.TC_string,
                                                 'test value')])
        self.pagetable_mock.getRowId(2).AndReturn(12)

        self.corba_mock.ReplayAll()
        table = IterTable("test_req_object", test_corba_session_string, pagesize=50)
        row = table._get_row(2)

        assert len(row) == 2

        assert row[0]['url'] == "www.test.foo/baz/detail/?id=12"
        assert row[0]['index'] == 0
        assert row[0]['icon'] is not None

        assert row[1]['index'] == 1
        assert row[1]['value'] == 'test value'

        self.corba_mock.VerifyAll()
Exemplo n.º 8
0
    def test__get_row(self):
        """_get_row returns row correctly. """
        self.init_itertable(self.pagetable_mock, pageSize=50)
        self.pagetable_mock.getRow(2).AndReturn(
            [CORBA.Any(CORBA.TC_string, 'test value')])
        self.pagetable_mock.getRowId(2).AndReturn(12)

        self.corba_mock.ReplayAll()
        table = IterTable("test_req_object",
                          test_corba_session_string,
                          pagesize=50)
        row = table._get_row(2)

        assert len(row) == 2

        assert row[0]['url'] == "www.test.foo/baz/detail/?id=12"
        assert row[0]['index'] == 0
        assert row[0]['icon'] is not None

        assert row[1]['index'] == 1
        assert row[1]['value'] == 'test value'

        self.corba_mock.VerifyAll()
Exemplo n.º 9
0
    def test__get_row(self):
        """_get_row returns row correctly. """
        self.init_itertable(pageSize=50)

        self.pagetable_mock.getRow.side_effect = lambda row_num: \
            [CORBA.Any(CORBA.TC_string, 'test value')] if row_num == 2 else None
        self.pagetable_mock.getRowId.side_effect = lambda row_num: \
            12 if row_num == 2 else None
        table = IterTable('test_req_object',
                          test_corba_session_string,
                          pagesize=50)
        row = table._get_row(2)

        assert_equal(len(row), 2)

        assert_equal(row[0]['url'], "www.test.foo/baz/detail/?id=12")
        assert_equal(row[0]['index'], 0)
        assert_is_not_none(row[0]['icon'])

        assert_equal(row[1]['index'], 1)
        assert_equal(row[1]['value'], 'test value')

        expected_calls = [call.getRow(2), call.getRowId(2)]
        self.pagetable_mock.assert_has_calls(expected_calls, any_order=True)