fixes
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
print("proxy module loaded!")
|
|
||||||
def proxy_app():
|
def proxy_app():
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(Config)
|
|
||||||
|
|
||||||
# Подключаем маршруты
|
|
||||||
from proxy import rss_proxy, healthcheck
|
from proxy import rss_proxy, healthcheck
|
||||||
rss_proxy.init_proxy(app)
|
rss_proxy.init_proxy(app)
|
||||||
healthcheck.init_healthcheck(app)
|
healthcheck.init_healthcheck(app)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import unittest
|
|||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
from proxy import proxy_app
|
from proxy import proxy_app
|
||||||
|
|
||||||
|
|
||||||
class FlaskTestCase(unittest.TestCase):
|
class FlaskTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -28,7 +29,7 @@ class FlaskTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
response = self.app.get('/proxy?url=https://example.com/rss.xml')
|
response = self.app.get('/proxy?url=https://example.com/rss.xml')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertIn(b'<?xml version="1.0" encoding="UTF-8"?>', response.data) # Проверка перекодировки
|
self.assertIn(b'<?xml version="1.0" encoding="UTF-8"?>', response.data)
|
||||||
|
|
||||||
@patch("proxy.rss_proxy.requests.get")
|
@patch("proxy.rss_proxy.requests.get")
|
||||||
def test_proxy_missing_url(self, mock_get):
|
def test_proxy_missing_url(self, mock_get):
|
||||||
@@ -46,5 +47,6 @@ class FlaskTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(response.status_code, 500)
|
self.assertEqual(response.status_code, 500)
|
||||||
self.assertIn(b'Error: Request failed', response.data)
|
self.assertIn(b'Error: Request failed', response.data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user