Pridana kontrola migraci pohadky.
This commit is contained in:
		
							parent
							
								
									4c99bb88db
								
							
						
					
					
						commit
						49cc21b040
					
				
					 1 changed files with 22 additions and 1 deletions
				
			
		|  | @ -38,7 +38,7 @@ def check_same(old_row, new_row, old_fields, new_fields=None): | ||||||
| 	for old_field, new_field in fields: | 	for old_field, new_field in fields: | ||||||
| 		if old_row[old_field] == new_row[new_field]: | 		if old_row[old_field] == new_row[new_field]: | ||||||
| 			continue | 			continue | ||||||
| 		raise ValueError(f"Fields '{old_field}' and '{new_field}' differs for rows '{old_row}' and '{new_row}'") | 		raise ValueError(f"Fields '{old_field}' and '{new_field}' differs for rows \n'{old_row}' and \n'{new_row}'") | ||||||
| 	return True | 	return True | ||||||
| 
 | 
 | ||||||
| def get_user_id_for_org_id(org_id): | def get_user_id_for_org_id(org_id): | ||||||
|  | @ -139,6 +139,26 @@ def check_novinky(): | ||||||
| 		if get_user_id_for_org_id(n['autor_id']) != o['autor_id']: | 		if get_user_id_for_org_id(n['autor_id']) != o['autor_id']: | ||||||
| 			raise ValueError("Nesedi autori u novinek") | 			raise ValueError("Nesedi autori u novinek") | ||||||
| 			 | 			 | ||||||
|  | def check_pohadka(): | ||||||
|  | 	old_query = "SELECT * FROM seminar_pohadky ORDER BY id" | ||||||
|  | 	new_query = """SELECT sp.id AS id, sp.autor_id AS autor_id, sp.vytvoreno AS vytvoreno, snp.treenode_ptr_id AS treenode_ptr_id, st.na_web AS text | ||||||
|  | 			FROM seminar_pohadky AS sp  | ||||||
|  | 			INNER JOIN seminar_nodes_pohadka AS snp ON sp.id = snp.pohadka_id  | ||||||
|  | 			INNER JOIN seminar_nodes_treenode AS snt ON snt.id = snp.treenode_ptr_id | ||||||
|  | 			INNER JOIN seminar_nodes_obsah AS sno ON sno.treenode_ptr_id = snt.first_child_id  | ||||||
|  | 			INNER JOIN seminar_texty AS st ON sno.text_id = st.id | ||||||
|  | 
 | ||||||
|  | 			ORDER BY sp.id""" | ||||||
|  | 
 | ||||||
|  | 	old_res, new_res = execute_simple(old_query,new_query) | ||||||
|  | 	res = zip(old_res,new_res) | ||||||
|  | 
 | ||||||
|  | 	for o,n in res: | ||||||
|  | 		check_same(o,n,['id','timestamp','text'],['id','vytvoreno','text']) | ||||||
|  | 		if o['autor_id'] is not None: | ||||||
|  | 			if get_user_id_for_org_id(n['autor_id']) != o['autor_id']: | ||||||
|  | 				raise ValueError("Nesedi autori u pohadky") | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -153,3 +173,4 @@ check_soustredeni_ucastnici() | ||||||
| check_soustredeni_organizatori() | check_soustredeni_organizatori() | ||||||
| check_nastaveni() | check_nastaveni() | ||||||
| check_novinky() | check_novinky() | ||||||
|  | check_pohadka() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue