Esempio n. 1
0
def test_invalid_url_get_file_video():
    with pytest.raises(NotFound) as excinfo:
        url = 'https://www.invalid-url'
        scrape = Scrape()
        scrape.get_file_video(url)

    assert excinfo.typename == 'NotFound'
    assert excinfo.value.status_code == 404
    assert excinfo.value.detail == _('Invalid url information')
Esempio n. 2
0
 def post(self, request, format=None):
     serializer = FileVideoSerializer(data=request.data)
     if serializer.is_valid() is False:
         return Response(serializer.errors, status=400)
     else:
         scrape = Scrape()
         page = scrape.get_file_video(serializer.data['url'])
         if page.status_code == 200:
             videos_json = scrape.scraping_file_video(page.text)
         else:
             videos_json = {'error': _('File video not found!')}
         return JsonResponse(videos_json, safe=False)
Esempio n. 3
0
def test_get_file_video():
    url = 'https://www.camara.leg.br/evento-legislativo/59733/sessao/523169/video-trecho/1594254243193'  # NOQA
    responses.add(responses.GET,
                  url,
                  body=HTML_FILE_VIDEO,
                  status=200)

    scrape = Scrape()
    response = scrape.get_file_video(url)

    assert response.status_code == 200
    assert len(responses.calls) == 1
    assert response.text == HTML_FILE_VIDEO