def setUp(self):
        app.app_context().push()
        db.create_all()
        collected_date_value = datetime.strptime('2018-06-14',
                                                 '%Y-%m-%d').date()
        actor_db = {
            'actor_name': 'Marina Silva',
            'actor_username': '******',
            'channel_id': 'channel_id_value',
            'title': 'Marina Silva',
            'subscribers': 13515,
            'video_count': 876,
            'view_count': 4307555,
            'created_date': '2010-01-26',
            'keywords': 'keywords_value',
            'collected_date': collected_date_value,
            'thumbnail_url': 'thumbnail_url_value',
            'description': 'description_value',
            'banner_url': 'banner_url_value',
            'hundred_thousand': False
        }

        DBYouTube.add_actor(actor_db)

        video_db = {
            'views': '1',
            'title': 'Video Marina Silva',
            'likes': '1',
            'dislikes': '1',
            'comments': '1',
            'favorites': '1',
            'url': 'url Marina Silva',
            'publishedAt': 'data publicação',
            'description': 'descrição',
            'tags': 'tags',
            'embeddable': 'embeddable',
            'duration': 'duration',
            'thumbnail': 'thumbnail',
            'category': 'category',
            'collected_date': collected_date_value,
            'channel_id': 'channel_id_value',
            'video_id': '1'
        }

        DBYouTube.add_videos(video_db)

        related_video_db = {
            'title': 'Related title',
            'likes': '34',
            'views': '8234',
            'dislikes': '3',
            'comments': '2',
            'favorites': '10',
            'url': 'https://www.youtube.com/watch?v=hFc_scYRasdY',
            'publishedAt': '2015-12-13T17:37:01.000Z',
            'description': '',
            'tags': 'disabled',
            'embeddable': 'True',
            'duration': 'PT4H24M20S',
            'thumbnail': 'https://i.ytimg.com/vi/hFc_sasdRpQY/hqdefault.jpg',
            'category': 'Entretenimento',
            'video_id': '2',
            'collected_date': collected_date_value,
            'channel_id': 'channel_id_value'
        }

        DBYouTube.add_videos(related_video_db)

        DBYouTube.add_relationship_videos('2', collected_date_value, '1')
        DBYouTube.add_actor_video_relationship('1', 'channel_id_value',
                                               collected_date_value)

        self.app = app.test_client()
        # Propaga as exceções para o cliente de teste
        self.app.testing = True
Ejemplo n.º 2
0
                             collected_date=YoutubeAPI.start_time,
                             thumbnail_url=channel_thumbnail,
                             description=description,
                             keywords=keywords,
                             banner_url=banner_thumbnail,
                             above_one_hundred_thousand=hundred_thousand)

            db.session.add(actor_db)
            db.session.commit()
            time.sleep(0.02)
            videos_views = video.get_all_video_views_user_id(
                response, parameters['video_limit'],
                parameters['related_video_limit'])

            if videos_views:
                for item in videos_views:
                    related_videos = item['related_to_video']
                    item['collected_date'] = YoutubeAPI.start_time
                    item['channel_id'] = channel_id
                    DBYouTube.add_videos(item)
                    DBYouTube.add_actor_video_relationship(
                        item['video_id'], channel_id, YoutubeAPI.start_time)
                    for related_video in related_videos:
                        related_video['collected_date'] = YoutubeAPI.start_time
                        related_video['channel_id'] = channel_id
                        DBYouTube.add_videos(related_video)
                        DBYouTube.add_relationship_videos(
                            child_video_id=related_video['video_id'],
                            parent_date=YoutubeAPI.start_time,
                            parent_id=item['video_id'])