Beispiel #1
0
    def test_available_dsrc_xml(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))
        el = MYSQLDataBase()
        self.assertTrue(isinstance(el, object))
        self.connect(el)
        avc = el.availableDataSources()
        self.assertTrue(isinstance(avc, list))
        name = "mcs_test_datasource"
        xml = "<?xml version='1.0'?><definition><group type='NXentry'/>" \
              + "</definition>"
        while name in avc:
            name = name + '_1'
#        print(avc
        cpx = el.dataSources(avc)
        self.assertEqual(el.storeDataSource(name, xml), None)
        self.__ds.append(name)
        avc2 = el.availableDataSources()
#        print(avc2
        cpx2 = el.dataSources(avc2)
        self.assertTrue(isinstance(avc2, list))
        for i in range(len(avc)):
            self.assertTrue(avc[i] in avc2)
            j = avc2.index(avc[i])
            self.assertEqual(cpx2[j], cpx[i])

        self.assertTrue(name in avc2)
        j = avc2.index(name)
        self.assertEqual(cpx2[j], xml)

        self.assertEqual(el.deleteDataSource(name), None)
        self.__ds.pop()

        avc3 = el.availableDataSources()
        cpx3 = el.dataSources(avc3)
        self.assertTrue(isinstance(avc3, list))

        for i in range(len(avc)):
            self.assertTrue(avc[i] in avc3)
            j = avc3.index(avc[i])
            self.assertEqual(cpx3[j], cpx[i])

        self.assertTrue(name not in avc3)

        self.assertEqual(long(el.version()), self.version + 2)
        self.assertEqual(el.close(), None)
Beispiel #2
0
    def test_available_dsrc_strange(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))
        el = MYSQLDataBase()
        self.assertTrue(isinstance(el, object))
        self.connect(el)
        avc = el.availableDataSources()
        self.assertTrue(isinstance(avc, list))
        name = "mcs_test_datasource\\ \' \" \\\" \\\\"
        xml = "<?xml version='1.0'?><definition>\\ \' \" \\\" " \
              + "\\\\<group type='NXentry'/></definition>"
        while name in avc:
            name = name + '_1'
#        print(avc
        self.assertEqual(el.storeDataSource(name, xml), None)
        self.assertEqual(el.storeDataSource(name, xml), None)
        self.__ds.append(name)
        avc2 = el.availableDataSources()
#        print(avc2
        self.assertTrue(isinstance(avc2, list))
        for cp in avc:
            self.assertTrue(cp in avc2)

        self.assertTrue(name in avc2)
        cpx = el.dataSources([name])
        self.assertEqual(cpx[0], xml)

        self.assertEqual(el.deleteDataSource(name), None)
        self.__ds.pop()

        avc3 = el.availableDataSources()
        self.assertTrue(isinstance(avc3, list))
        for cp in avc:
            self.assertTrue(cp in avc3)
        self.assertTrue(name not in avc3)

        self.assertEqual(long(el.version()), self.version + 2)
        self.assertEqual(el.close(), None)
Beispiel #3
0
    def test_available_no_dsrc(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))
        el = MYSQLDataBase()
        self.assertTrue(isinstance(el, object))
        self.connect(el)
        avc = el.availableDataSources()
        self.assertTrue(isinstance(avc, list))
        name = "mcs_test_datasource"
        while name in avc:
            name = name + '_1'
#        print(avc
        self.myAssertRaise(NonregisteredDBRecordError, el.dataSources, [name])

        self.assertEqual(long(el.version()), self.version)
        self.assertEqual(el.close(), None)