def test_delete_gif_group_id_and_index(self):
        print('Testing delete_gif_group_id_and_index()')
        GifService.add_new_gif(Gif(groupId=1, gifUrl='url2'))
        GifService.add_new_gif(Gif(groupId=1, gifUrl='url3'))

        GifService.delete_gif_by_group_id_and_index(groupId=1, index=2)
        gifsPage = GifService.get_all_gif()

        self._check_data(gif=gifsPage[0], groupId=1, gifUrl='url1')
        self._check_data(gif=gifsPage[1], groupId=1, gifUrl='url3')
        print('Successful\n')
def get_gif(groupId: int, index: int):
    row = Repos.get_gif(groupId=groupId, index=index - 1)
    if row is None:
        raise ValueError(
            'GifGroupService.get_gif_by_group_id_and_index(): returned row is null'
        )
    return Gif(groupId=row[0], gifUrl=row[1])
    def test_get_gif_page_by_group_id_and_index(self):
        print('Testing get_gif_page_by_group_id_and_index()')
        GifService.add_new_gif(Gif(groupId=1, gifUrl='url4'))

        gifsPage = GifService.get_gif_page(groupId=1, index=2)

        self._check_data(gif=gifsPage[0], groupId=1, gifUrl='url2')
        self._check_data(gif=gifsPage[2], groupId=1, gifUrl='url4')
        self.assertEqual(
            3, len(gifsPage),
            'rows_count should be {0} actual {1}'.format(3, len(gifsPage)))
        print('Successful\n')
    def test_add_new_gif_and_get_all(self):
        print('Testing add_new_gif() and get_all()')
        GifService.add_new_gif(gif=Gif(groupId=2, gifUrl='2url2'))

        answer = GifService.get_all_gif()

        self.assertEqual(
            5, len(answer),
            'rows_count should be {0} actual {1}'.format(5, len(answer)))
        self._check_data(answer[0], groupId=1, gifUrl='url1')
        self._check_data(answer[4], groupId=2, gifUrl='2url2')
        print('Successful\n')
def get_gif_page(groupId: int, index: int):
    rows = Repos.get_gif_page(groupId=groupId, index=index - 1)
    answer = []
    for row in rows:
        answer.append(Gif(groupId=row[0], gifUrl=row[1]))
    return answer
def get_all_gif():
    rows = Repos.get_all_gif()
    return [Gif(groupId=row[0], gifUrl=row[1]) for row in rows]
 def setUp(self):
     GifService.clear_table()
     GifService.add_new_gif(Gif(groupId=1, gifUrl='url1'))
     GifService.add_new_gif(Gif(groupId=1, gifUrl='url2'))
     GifService.add_new_gif(Gif(groupId=1, gifUrl='url3'))
     GifService.add_new_gif(Gif(groupId=2, gifUrl='2url1'))
cursor = connection.cursor()
print('connected: ' + path2)

# ========== table 1 ===========
cursor.execute(""" SELECT * FROM triggers """)
data = cursor.fetchall()
idDict = {}
i = 1
for row in data:
    newGifGroup = GifGroup(name=row[0],
                           authorId=row[1],
                           phrase=row[2],
                           accessLevel=row[3],
                           createDate=datetime.strftime(
                               datetime.now(), "%Y-%m-%d"))
    GifGroupService.add_new_gif_group_full(gifGroup=newGifGroup)
    idDict[row[0]] = i
    i += 1

# ========== table 2 ===========
cursor.execute(""" SELECT * FROM gif """)
data = cursor.fetchall()

for row in data:
    newGif = Gif(groupId=idDict[row[0]], gifUrl=row[1])
    GifService.add_new_gif(gif=newGif)

print('data copied')
connection.close()
print('connection closed')