コード例 #1
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_del_element(self):
    
        beliefs = {'book_title':'/bookstore/book[1]/title'}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/title'),'Everyday Italian')
        
        del d.book_title

        with assert_raises(XmlDogmaException):  
            d._get('/bookstore/book[1]/title')
        with assert_raises(DogmaGetterSetterException):
            d.book_title
コード例 #2
0
    def dont_txxt_dogma_del_element(self):
    
        beliefs = {'book_title':'/bookstore/book[1]/title'}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/title'),'Everyday Italian')
        
        del d.book_title

        with assert_raises(XmlDogmaException):  
            d._get('/bookstore/book[1]/title')
        with assert_raises(DogmaGetterSetterException):
            d.book_title
コード例 #3
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_del_attribute(self):
    
        beliefs = {'book_category':'/bookstore/book[1]/@category'}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        
        del d.book_category

        with assert_raises(XmlDogmaException):
            d._get('/bookstore/book[1]/@category')
            
        with assert_raises(DogmaGetterSetterException):
            assert_equal(d.book_category, None)
コード例 #4
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_get_nonexisting(self):

        beliefs = {'book_title':'/bookstore/book[5]/title',
        'childrens_title':"""/bookstore/book[@category = 'CHILDREN']/title"""}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
        
        with assert_raises(XmlDogmaException):
            d._get('bzzz')

        with assert_raises(DogmaGetterSetterException):
            d.book_title

        with assert_raises(AttributeError):
            d.not_an_att
コード例 #5
0
    def dont_txxt_dogma_del_attribute(self):
    
        beliefs = {'book_category':'/bookstore/book[1]/@category'}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        
        del d.book_category

        with assert_raises(XmlDogmaException):
            d._get('/bookstore/book[1]/@category')
            
        with assert_raises(DogmaGetterSetterException):
            assert_equal(d.book_category, None)
コード例 #6
0
    def test_dogma_get_nonexisting(self):

        beliefs = {'book_title':'/bookstore/book[5]/title',
        'childrens_title':"""/bookstore/book[@category = 'CHILDREN']/title"""}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
        
        with assert_raises(XmlDogmaException):
            d._get('bzzz')

        with assert_raises(DogmaGetterSetterException):
            d.book_title

        with assert_raises(AttributeError):
            d.not_an_att
コード例 #7
0
ファイル: test_xml_dogma.py プロジェクト: ioos/wicken
    def test_dogma_get_element(self):

        beliefs = {
            'book_title': '/bookstore/book[1]/title',
            'no_title': '/bookstore/book[5]/title',
            'childrens_title':
            """/bookstore/book[@category = 'CHILDREN']/title""",
            'childrens_year':
            """/bookstore/book[@category = 'CHILDREN']/year"""
        }
        dataObject = etree.parse(BytesIO(BOOKS))

        d = XmlDogma('Books', beliefs, dataObject)

        self.assertEqual(d._get('/bookstore/book[1]/title'),
                         'Everyday Italian')

        self.assertEqual(d.book_title, 'Everyday Italian')

        self.assertEqual(d.childrens_title, 'Harry Potter')

        self.assertEqual(d.childrens_year, '2005')

        with self.assertRaises(DogmaGetterSetterException):
            d.no_title
コード例 #8
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_set_attribute_text(self):
    
        beliefs = {'book_category':'/bookstore/book[1]/@category'} 
        
        # Set the text using _set
        dataObject = etree.parse(StringIO(BOOKS))  
        d = XmlDogma('Books',beliefs,dataObject)
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        d._set('/bookstore/book[1]/@category','FOOBAR')
        assert_equal(d._get('/bookstore/book[1]/@category'),'FOOBAR')

        # Set using the attribute
        dataObject = etree.parse(StringIO(BOOKS))  
        d = XmlDogma('Books',beliefs,dataObject)
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        d.book_category = 'CLEANING'
        assert_equal(d._get('/bookstore/book[1]/@category'),'CLEANING')
コード例 #9
0
    def dont_txxt_dogma_set_attribute_text(self):
    
        beliefs = {'book_category':'/bookstore/book[1]/@category'} 
        
        # Set the text using _set
        dataObject = etree.parse(StringIO(BOOKS))  
        d = XmlDogma('Books',beliefs,dataObject)
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        d._set('/bookstore/book[1]/@category','FOOBAR')
        assert_equal(d._get('/bookstore/book[1]/@category'),'FOOBAR')

        # Set using the attribute
        dataObject = etree.parse(StringIO(BOOKS))  
        d = XmlDogma('Books',beliefs,dataObject)
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        d.book_category = 'CLEANING'
        assert_equal(d._get('/bookstore/book[1]/@category'),'CLEANING')
コード例 #10
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_get_existing_attribute(self):
    
        beliefs = {'book_category':'/bookstore/book[1]/@category'}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        
        assert_equal(d.book_category, 'COOKING') 
コード例 #11
0
    def test_dogma_get_existing_attribute(self):
    
        beliefs = {'book_category':'/bookstore/book[1]/@category'}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/@category'),'COOKING')
        
        assert_equal(d.book_category, 'COOKING') 
コード例 #12
0
ファイル: test_xml_dogma.py プロジェクト: ioos/wicken
    def dont_txxt_dogma_set_element_text(self):

        beliefs = {
            'book_title': '/bookstore/book[1]/title',
            'childrens_title':
            """/bookstore/book[@category = 'CHILDREN']/title"""
        }

        # Set the text using _set
        dataObject = etree.parse(BytesIO(BOOKS))
        d = XmlDogma('Books', beliefs, dataObject)
        self.assertEqual(d._get('/bookstore/book[1]/title'),
                         'Everyday Italian')
        d._set('/bookstore/book[1]/title', 'Z french is better!')
        self.assertEqual(d._get('/bookstore/book[1]/title'),
                         'Z french is better!')

        # Set using the attribute
        dataObject = etree.parse(BytesIO(BOOKS))
        d = XmlDogma('Books', beliefs, dataObject)
        self.assertEqual(d._get('/bookstore/book[1]/title'),
                         'Everyday Italian')
        d.book_title = 'Z french is better!'
        self.assertEqual(d._get('/bookstore/book[1]/title'),
                         'Z french is better!')

        self.assertEqual(
            d._get("""/bookstore/book[@category = 'CHILDREN']/title"""),
            'Harry Potter')
        d.childrens_title = 'potter harry'
        self.assertEqual(
            d._get("""/bookstore/book[@category = 'CHILDREN']/title"""),
            'potter harry')
コード例 #13
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_get_element(self):
    
        beliefs = {'book_title':'/bookstore/book[1]/title',
        'no_title':'/bookstore/book[5]/title',
        'childrens_title':"""/bookstore/book[@category = 'CHILDREN']/title""",
        'childrens_year':"""/bookstore/book[@category = 'CHILDREN']/year"""}
        dataObject = etree.parse(StringIO(BOOKS))        

        d = XmlDogma('Books',beliefs,dataObject)
       
        assert_equal(d._get('/bookstore/book[1]/title'),'Everyday Italian')
        
        assert_equal(d.book_title, 'Everyday Italian') 
       
        assert_equal(d.childrens_title, 'Harry Potter')
        
        assert_equal(d.childrens_year, '2005')
        
        with assert_raises(DogmaGetterSetterException):
            d.no_title
コード例 #14
0
ファイル: xml_dogma_tests.py プロジェクト: daf/wicken
    def test_dogma_set_element_text(self):
    
        beliefs = {'book_title':'/bookstore/book[1]/title',
        'childrens_title':"""/bookstore/book[@category = 'CHILDREN']/title"""}
        
        
        # Set the text using _set
        dataObject = etree.parse(StringIO(BOOKS))  
        d = XmlDogma('Books',beliefs,dataObject)
        assert_equal(d._get('/bookstore/book[1]/title'),'Everyday Italian')
        d._set('/bookstore/book[1]/title','Z french is better!')
        assert_equal(d._get('/bookstore/book[1]/title'),'Z french is better!')

        # Set using the attribute
        dataObject = etree.parse(StringIO(BOOKS))  
        d = XmlDogma('Books',beliefs,dataObject)
        assert_equal(d._get('/bookstore/book[1]/title'),'Everyday Italian')
        d.book_title = 'Z french is better!'
        assert_equal(d._get('/bookstore/book[1]/title'),'Z french is better!')

        assert_equal(d._get("""/bookstore/book[@category = 'CHILDREN']/title"""),'Harry Potter')
        d.childrens_title = 'potter harry'
        assert_equal(d._get("""/bookstore/book[@category = 'CHILDREN']/title"""),'potter harry')