Example #1
0
    def __init__(self, name='not named'):
        DS_basic.__init__(self, name)

        self.ds_file = None                 #a file object, where the data source gets the data
        self.ds_filename = None             #the file name string of the underlying data file
        self.ds_table = None                #the table object, where the data source gets the data from
        self.ds_tablename = None            #the table name, that names the table in the underlying data file
        self.ds_reader = None               #a reader object, needed for providing the data one by one
Example #2
0
class TestOpenCloseDS_basic(unittest.TestCase):
    def setUp(self):
        print "\n Open / close the data source for DS_basic"
        self.ds = None
        self.ds = DS_basic("Test")

    def tearDown(self):
        pass

    def runTest(self):
        # Low level test, opening and closing of the data source
        if single_test:
            print "  Test opening / closing of data source (low level)"

        try:
            self.ds._open_data_source([])
        except:
            print "   Low level method _open_data_source() raised exception"

        try:
            self.ds._close_data_source()
        except:
            print "   Low level method _close_data_source() raised exception"

            # Function test for open() and close() method
        if single_test:
            print "  Open method for the DS_basic object"

        self.ds.open([])
        assert self.ds.ds_status == "open", "Method open() could not open the data source"
        self.ds.close()
        assert self.ds.ds_status == "closed", "Method close() could not close the data source"
Example #3
0
class TestNextDS_basic(unittest.TestCase):
    def setUp(self):
        print "\n Get next record from DS_basic"
        self.ds = None
        self.ds = DS_basic("Test")
        self.ds.open()

    def tearDown(self):
        try:
            self.ds.close()
        except:
            pass

    def runTest(self):
        # Low level test, get the next record with _get_next_record method
        if single_test:
            print "  Test _get_next_record (Low level)"

        rec = None
        procBytes = self.ds.ds_processedBytes
        try:
            rec = self.ds._get_next_record()
        except:
            print "  Low level method _get_next_record() raised exception"
        assert rec != None, "Method _get_next_record did not return a record"
        assert rec.__class__.__name__ == "dict", "Method _get_next_record did not return a dictionary as record"
        assert (
            self.ds.ds_processedBytes != procBytes
        ), "Method _get_next_record did not change number of processed Bytes"

        if single_test:
            print "  Test next() method - single shot"

        rec = None
        try:
            rec = self.ds.next()
        except:
            print "  Method next() raised exception"
        assert rec != None, "Method next() did not return a record"
        assert rec.__class__.__name__ == "dict", "Method next() did not return a dictionary as record"
        assert self.ds.ds_numRows == 1, "Method next() did not count number of Rows provided"
        assert self.ds.ds_processedBytes == 44, "Counting of processed Bytes did not work properly"

        if single_test:
            print "  Test next() method - repeated calls"

        try:
            count = 0
            while count < 10:
                rec = self.ds.next()
                assert rec != None, "Method next() did not return a record"
                assert rec.__class__.__name__ == "dict", "Method next() did not return a dictionary as record"
                count += 1
        except:
            print "  Test next() method - repeated calls raised exception"

        assert self.ds.ds_numRows == 11, "Method next() did not count number of Rows provided"
        # print self.ds.ds_processedBytes
        assert self.ds.ds_processedBytes == 264, "Counting of processed Bytes did not work properly"
Example #4
0
    def runTest(self):
        if single_test:
            print "\n  Initialisation of DS_basic object"

        self.ds = None
        self.ds = DS_basic("Test")
        assert self.ds != None, "Could not instantiate an object for the class"

        if single_test:
            print "  Default values for instance variables"

        assert self.ds.ds_name == "Test", "Initialisation of Name failed"
        assert self.ds.ds_status == "closed", "Initialisation of Status failed"
        assert self.ds.ds_statInfo == False, "Initialisation of statInfo failed"
        assert self.ds.ds_numRows == 0, "Initialisation of numRows failes"
        assert self.ds.ds_processedBytes == 0, "Initialisation of processedBytes failed"
        assert self.ds.ds_limitRows == -1, "Initialisation of limitRows failed"

        if single_test:
            print "  Get methods for instance variables"

        assert self.ds.get_name() == "Test", "Method get_name failed"
        assert self.ds.get_status() == "closed", "Method get_status failed"
        assert self.ds.get_statInfo() == False, "Method get_statInfo failed"
        assert self.ds.get_numRows() == 0, "Method get_numRows failed"
        assert self.ds.get_processedBytes() == 0, "Method get_processedBytes failed"
        assert self.ds.get_limitRows() == -1, "Method get_limitRows failed"

        if single_test:
            print "  Set methods for instance variables"

        self.ds.set_statInfo(True)
        assert self.ds.ds_statInfo == True, "Method set_statInfo could not set statInfo"
        self.ds.set_statInfo(False)
        assert self.ds.ds_statInfo == False, "Method set_statInfo could not reset statInfo"

        self.ds.set_limitRows(10)
        assert self.ds.ds_limitRows == 10, "Method set_limitRows could not set limitRows"
        self.ds.set_limitRows(-1)
        assert self.ds.ds_limitRows == -1, "Method set_limitRows could not reset limitRows"
Example #5
0
 def setUp(self):
     print "\n Open / close the data source for DS_basic"
     self.ds = None
     self.ds = DS_basic("Test")
Example #6
0
 def setUp(self):
     print "\n Get next record from DS_basic"
     self.ds = None
     self.ds = DS_basic("Test")
     self.ds.open()
Example #7
0
    def __init__(self, name="not named"):
        DS_basic.__init__(self, name)

        self.ds_file = None  # a file object, where the data source gets the data
        self.ds_fldSep = ";"  # the field separator to be used in the csv data source
        self.ds_filename = None  # the file name string of the underlying data file