mirror of
				https://github.com/qurator-spk/modstool.git
				synced 2025-11-03 19:04:13 +01:00 
			
		
		
		
	✔️ Add METS tests
This commit is contained in:
		
							parent
							
								
									f7c51d127d
								
							
						
					
					
						commit
						86d1154638
					
				
					 1 changed files with 35 additions and 0 deletions
				
			
		
							
								
								
									
										35
									
								
								qurator/modstool/tests/test_mets.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								qurator/modstool/tests/test_mets.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
import pytest
 | 
			
		||||
import xml.etree.ElementTree as ET
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from .. import mets_to_dict, flatten
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def dict_fromstring(x):
 | 
			
		||||
   """Helper function to parse a METS/MODS XML string to a flattened dict"""
 | 
			
		||||
   return flatten(mets_to_dict(ET.fromstring(x)))
 | 
			
		||||
   # XXX move to test lib
 | 
			
		||||
 | 
			
		||||
def test_fileGrp():
 | 
			
		||||
    """
 | 
			
		||||
    Elements of mets:fileGrp should be counted
 | 
			
		||||
    """
 | 
			
		||||
    d = dict_fromstring("""
 | 
			
		||||
    <mets:mets xmlns:mets="http://www.loc.gov/METS/">
 | 
			
		||||
 | 
			
		||||
    <mets:fileSec>
 | 
			
		||||
    <mets:fileGrp USE="PRESENTATION">
 | 
			
		||||
      <mets:file ID="FILE_0001_PRESENTATION" MIMETYPE="image/tiff">
 | 
			
		||||
        <mets:FLocat xmlns:xlink="http://www.w3.org/1999/xlink" LOCTYPE="URL" xlink:href="file:///goobi/tiff001/sbb/PPN1678618276/00000001.tif"/>
 | 
			
		||||
      </mets:file>
 | 
			
		||||
      <mets:file ID="FILE_0002_PRESENTATION" MIMETYPE="image/tiff">
 | 
			
		||||
        <mets:FLocat xmlns:xlink="http://www.w3.org/1999/xlink" LOCTYPE="URL" xlink:href="file:///goobi/tiff001/sbb/PPN1678618276/00000002.tif"/>
 | 
			
		||||
      </mets:file>
 | 
			
		||||
      <mets:file ID="FILE_0003_PRESENTATION" MIMETYPE="image/tiff">
 | 
			
		||||
        <mets:FLocat xmlns:xlink="http://www.w3.org/1999/xlink" LOCTYPE="URL" xlink:href="file:///goobi/tiff001/sbb/PPN1678618276/00000003.tif"/>
 | 
			
		||||
      </mets:file>
 | 
			
		||||
    </mets:fileGrp>
 | 
			
		||||
    </mets:fileSec>
 | 
			
		||||
    </mets:mets>
 | 
			
		||||
    """)
 | 
			
		||||
    assert d['fileSec_fileGrp-PRESENTATION-count'] == 3
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue