Exemplo n.º 1
0
    def test_available_sel_update(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.availableSelections()
        self.assertTrue(isinstance(avc, list))
        name = "mcs_test_selection"
        xml = "<?xml version='1.0'?><definition><group type='NXentry'/>" \
              + "</definition>"
        xml2 = "<?xml version='1.0'?><definition><group type='NXentry2'/>" \
               + "</definition>"
        while name in avc:
            name = name + '_1'
#        print(avc
        cpx = el.selections(avc)

        self.assertEqual(el.storeSelection(name, xml), None)
        self.__cmps.append(name)
        avc2 = el.availableSelections()
#        print(avc2
        cpx2 = el.selections(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.storeSelection(name, xml2), None)
        self.__cmps.append(name)
        avc2 = el.availableSelections()
#        print(avc2
        cpx2 = el.selections(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], xml2)

        self.assertEqual(el.deleteSelection(name), None)
        self.__cmps.pop()

        avc3 = el.availableSelections()
        cpx3 = el.selections(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)
        self.assertEqual(el.close(), None)
Exemplo n.º 2
0
    def test_mandatory_comp2(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)
        man = el.mandatory()
        self.assertTrue(isinstance(man, list))
        avc = el.availableComponents()

        name = "mcs_test_component"
        xml = "<?xml version='1.0'?><definition><group type='NXentry'/>" \
              + "</definition>"
        while name in avc:
            name = name + '_1'

        name2 = name + '_2'
        while name2 in avc:
            name2 = name2 + '_2'
#        print(avc

        self.assertEqual(el.storeComponent(name, xml), None)
        self.__cmps.append(name)

#        print(man
        self.assertEqual(el.setMandatory(name), None)
        man2 = el.mandatory()
        self.assertEqual(len(man) + 1, len(man2))
        for cp in man:
            self.assertTrue(cp in man2)

        self.assertTrue(name in man2)

        self.assertEqual(el.storeComponent(name2, xml), None)
        self.__cmps.append(name2)

#        print(man
        self.assertEqual(el.setMandatory(name2), None)
        man2 = el.mandatory()
        self.assertEqual(len(man) + 2, len(man2))
        for cp in man:
            self.assertTrue(cp in man2)

        self.assertTrue(name in man2)
        self.assertTrue(name2 in man2)

        self.assertEqual(el.unsetMandatory(name), None)


#        print(<man
        man2 = el.mandatory()
        self.assertEqual(len(man) + 1, len(man2))
        for cp in man:
            self.assertTrue(cp in man2)

        self.assertTrue(name2 in man2)

        self.assertEqual(el.unsetMandatory(name2), None)

        man2 = el.mandatory()
        self.assertEqual(len(man), len(man2))
        for cp in man:
            self.assertTrue(cp in man2)

        self.assertTrue(name not in man2)

        self.assertEqual(el.deleteComponent(name), None)
        self.__cmps.pop()
        self.assertEqual(el.deleteComponent(name2), None)
        self.__cmps.pop()

        man2 = el.mandatory()
        self.assertEqual(len(man), len(man2))
        for cp in man:
            self.assertTrue(cp in man2)

        self.assertTrue(name not in man2)

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