Exemple #1
0
    def test_eq(self):
        self.assertEquals(ODBCConfig(), ODBCConfig())

        configA = ODBCConfig(data=self.simple_data)
        configB = ODBCConfig()
        configB.sources = {'testdb' : self.ACCESS_CONFIGSTR}
        configB.source_specs = {'testdb' : {'Database' : 'testdb.mdb'}}
        self.assertEquals(configA, configB)
Exemple #2
0
 def test_del_source_dependent(self):
     config = ODBCConfig()
     config.add_source("testdb", self.ACCESS_CONFIGSTR)
     config.add_source_spec("testdb", {'Database': "testdb.mdb"})
     config.del_source("testdb")
     self.assertEquals({}, config.sources)
     self.assertEquals({}, config.source_specs)
Exemple #3
0
 def test_init_simple_data(self):
     config = ODBCConfig(data=self.simple_data)
     self.assertEquals({'testdb': self.ACCESS_CONFIGSTR}, config.sources)
     self.assertEquals({'testdb': {
         'Database': "testdb.mdb"
     }}, config.source_specs)
     self.assertEquals({}, config.odbc_info)
Exemple #4
0
    def test_baselines(self):
        filenames = ['simple_odbc', 'diet']
        basePath = os.path.split(os.path.abspath(__file__))[0]
        for fn in filenames:
            iniPath = os.path.join(basePath, 'baselines', '{0}.ini'.format(fn))
            outPath = os.path.join(basePath, 'baselines', '{0}.out'.format(fn))

            config = ODBCConfig(filename=iniPath)
            config.write(outPath)

            written = ODBCConfig(filename = outPath)
            self.assertEquals(config, written)

            try:
                os.remove(outPath)
            except:
                pass
Exemple #5
0
    def test_baselines(self):
        filenames = ['simple_odbc', 'diet']
        basePath = os.path.split(os.path.abspath(__file__))[0]
        for fn in filenames:
            iniPath = os.path.join(basePath, 'baselines', '{0}.ini'.format(fn))
            outPath = os.path.join(basePath, 'baselines', '{0}.out'.format(fn))

            config = ODBCConfig(filename=iniPath)
            config.write(outPath)

            written = ODBCConfig(filename=outPath)
            self.assertEquals(config, written)

            try:
                os.remove(outPath)
            except:
                pass
Exemple #6
0
 def test_del_source_dependent(self):
     config = ODBCConfig()
     config.add_source("testdb", self.ACCESS_CONFIGSTR)
     config.add_source_spec("testdb", {'Database' : "testdb.mdb"})
     config.del_source("testdb")
     self.assertEquals({}, config.sources)
     self.assertEquals({}, config.source_specs)
Exemple #7
0
    def test_eq(self):
        self.assertEquals(ODBCConfig(), ODBCConfig())

        configA = ODBCConfig(data=self.simple_data)
        configB = ODBCConfig()
        configB.sources = {'testdb': self.ACCESS_CONFIGSTR}
        configB.source_specs = {'testdb': {'Database': 'testdb.mdb'}}
        self.assertEquals(configA, configB)
Exemple #8
0
 def test_add_source_spec(self):
     config = ODBCConfig()
     config.add_source("testdb", self.ACCESS_CONFIGSTR)
     config.add_source_spec("testdb", {'Database': "testdb.mdb"})
     self.assertEquals({'testdb': {
         'Database': "testdb.mdb"
     }}, config.source_specs)
Exemple #9
0
 def test_init_complex_data(self):
     config = ODBCConfig(data=self.complex_data)
     self.assertEquals(
         {
             'test1': self.ACCESS_CONFIGSTR,
             'test2': self.EXCEL_CONFIGSTR
         }, config.sources)
     self.assertEquals(
         {
             'test1': {
                 'Database': "test1.db",
                 'LogonID': "Admin",
                 'pwd': "secret_pass"
             },
             'test2': {
                 'Database': "test2.xls"
             }
         }, config.source_specs)
     self.assertEquals({'UNICODE': "UTF-8"}, config.odbc_info)
Exemple #10
0
 def test_add_source_reserved(self):
     config = ODBCConfig()
     with self.assertRaises(ODBCError):
         config.add_source("ODBC Data Sources", self.ACCESS_CONFIGSTR)
     with self.assertRaises(ODBCError):
         config.add_source("ODBC", self.ACCESS_CONFIGSTR)
Exemple #11
0
 def test_init_empty_data(self):
     config = ODBCConfig()
     self.assertEquals({}, config.sources)
     self.assertEquals({}, config.source_specs)
     self.assertEquals({}, config.odbc_info)
Exemple #12
0
 def test_create(self):
     config = ODBCConfig()
     self.assertIsNone(config.file)
Exemple #13
0
 def test_set_odbc_info(self):
     config = ODBCConfig()
     config.set_odbc_info("UNICODE", "UTF-8")
     self.assertEquals({'UNICODE' : "UTF-8"}, config.odbc_info)
Exemple #14
0
 def test_odbc_repr(self):
     config = ODBCConfig(data=self.simple_data)
     self.assertMultiLineEqual(config.odbc_repr(), self.simple_data)
Exemple #15
0
 def test_odbc_repr(self):
     config = ODBCConfig(data=self.simple_data)
     self.assertMultiLineEqual(config.odbc_repr(), self.simple_data)
Exemple #16
0
 def test_set_odbc_info(self):
     config = ODBCConfig()
     config.set_odbc_info("UNICODE", "UTF-8")
     self.assertEquals({'UNICODE': "UTF-8"}, config.odbc_info)
Exemple #17
0
 def test_add_source(self):
     config = ODBCConfig()
     config.add_source("testdb", self.ACCESS_CONFIGSTR)
     self.assertEquals({'testdb' : self.ACCESS_CONFIGSTR}, config.sources)
     self.assertEquals({}, config.source_specs)
     self.assertEquals({}, config.odbc_info)
Exemple #18
0
 def test_add_spec_bad(self):
     config = ODBCConfig()
     with self.assertRaises(ODBCError):
         config.add_source_spec("testdb", {'Database': "testdb.mdb"})
Exemple #19
0
 def test_add_spec_bad(self):
     config = ODBCConfig()
     with self.assertRaises(ODBCError):
         config.add_source_spec("testdb", {'Database' : "testdb.mdb"})
Exemple #20
0
 def test_del_source(self):
     config = ODBCConfig(data=self.simple_data)
     config.del_source('testdb')
     self.assertEquals({}, config.sources)
Exemple #21
0
 def test_add_source_reserved(self):
     config = ODBCConfig()
     with self.assertRaises(ODBCError):
         config.add_source("ODBC Data Sources", self.ACCESS_CONFIGSTR)
     with self.assertRaises(ODBCError):
         config.add_source("ODBC", self.ACCESS_CONFIGSTR)
Exemple #22
0
 def test_del_source(self):
     config = ODBCConfig(data=self.simple_data)
     config.del_source('testdb')
     self.assertEquals({}, config.sources)
Exemple #23
0
 def test_add_source(self):
     config = ODBCConfig()
     config.add_source("testdb", self.ACCESS_CONFIGSTR)
     self.assertEquals({'testdb': self.ACCESS_CONFIGSTR}, config.sources)
     self.assertEquals({}, config.source_specs)
     self.assertEquals({}, config.odbc_info)
Exemple #24
0
 def test_add_source_spec(self):
     config = ODBCConfig()
     config.add_source("testdb", self.ACCESS_CONFIGSTR)
     config.add_source_spec("testdb", {'Database' : "testdb.mdb"})
     self.assertEquals({'testdb' : {'Database' : "testdb.mdb"}}, config.source_specs)