# Тестирующая программа для новой версии Pycerebro
# для тестирования надо скопировать в папку test старую
# версию vista.py, переименовав её в old.py,
# Пример: test/old.py

from test import old as ovista
import vista as nvista

# 1 file and 2 versions
vista1 = nvista.Vista()

vista1.create_lista(lista_path='.lista1.sqlite3')
print('created vistas')

file = vista1.add_file()
file.from_dict({'flags': 0,
                'task_id': 145150779,
                'task_name': 'Lista',
                'url': '', 'name': '',
                'duration': 0, 'fps': 0})
print('added file')

vers = vista1.add_version(file_id=file.id)
vers.from_dict({'event_id': 145246760,
                'group_id': 0, 'flags': 0,
                'created_utc': 1689940422614,
                'name': 'SDKgtcbAYy8.jpg',
                'duration': 0, 'fps': 0,
                'path': '/home/cerebro_user/cerebro.files/тестирование/2023-07-12/SDKgtcbAYy8.jpg',
                'download_url': '', 'download_path': ''})
file.add_version(vers)
print('added 1st version')
print(vers.dict())

vers = vista1.add_version(file_id=file.id)
vers.from_dict({'event_id': 145246761,
                'group_id': 0, 'flags': 1,
                'created_utc': 1689940422615,
                'name': 'SDKgtcbAYy9.jpg',
                'duration': 0, 'fps': 0,
                'path': '/home/cerebro_user/cerebro.files/тестирование/2023-07-13/SDKgtcbAYy9.jpg',
                'download_url': '', 'download_path': ''})
file.add_version(vers)
print('added 2nd version')
print(vers.dict())

print(f'file: {file.dict()}')
print(f'vers1: {file.get_versions()[0].dict()}')
print(f'vers2: {file.get_versions()[1].dict()}')

vista2 = ovista.Vista()
vista2.create_lista(lista_path='.lista2.sqlite3')
print('created new vistas')

vista2.insert_file(list({'id': -2, 'flags': 0,
                'task_id': 145150779,
                'task_name': 'Lista',
                'url': '', 'name': '',
                'duration': 0, 'fps': 0}.values()))
print('added file')
print(vista2.query('SELECT * FROM files'))

vista2.insert_version(list({'id': -2, 'flags': 0, 'file_id': -2,
				'created_utc': 1689940422614,
                'name': 'SDKgtcbAYy8.jpg', 'event_id': 145246760, 
                'group_id': 0,
                'duration': 0, 'fps': 0,
                'path': '/home/cerebro_user/cerebro.files/тестирование/2023-07-12/SDKgtcbAYy8.jpg',
                'download_url': '', 'download_path': ''}.values()))
print('added 1st version')

vista2.insert_version(list({'id': -1, 'flags': 0, 'file_id': -2,
				'created_utc': 1689940422615,
                'name': 'SDKgtcbAYy9.jpg', 'event_id': 145246761, 
                'group_id': 0,
                'duration': 0, 'fps': 0,
                'path': '/home/cerebro_user/cerebro.files/тестирование/2023-07-13/SDKgtcbAYy9.jpg',
                'download_url': '', 'download_path': ''}.values()))
print('added 2nd version')

print('you can compare .lista1.sqlite3 and .lista2.sqlite3')

