Archived
删除历史版本, 初始化仓库
This commit is contained in:
37 files changed
+1773
No files matched your search
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/3/26
|
||||
# @File Name: __init__.py.py
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: Pycharm
|
||||
# @Create Time: 2022/5/1
|
||||
# @File Name: test_api.py
|
||||
|
||||
|
||||
import random
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
|
||||
class TestAPI(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.api = 'http://127.0.0.1:5000/api/v1/'
|
||||
|
||||
def test_query(self):
|
||||
res = requests.post(self.api + 'query', params={'name': 'test-example'})
|
||||
self.assertEqual(res.status_code, 200)
|
||||
|
||||
def test_query_failed(self):
|
||||
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
r_name = ''.join(random.choice(letters) for _ in range(10))
|
||||
res = requests.post(self.api + 'query', params={'name': r_name})
|
||||
self.assertEqual(res.status_code, 404)
|
||||
|
||||
def test_overall(self):
|
||||
res = requests.post(self.api + 'overall')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
|
||||
def test_alltables(self):
|
||||
res = requests.post(self.api + 'alltables')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
|
||||
def test_test(self):
|
||||
res = int(requests.post(self.api + 'test').text)
|
||||
self.assertIs(type(res), int)
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: Pycharm
|
||||
# @Create Time: 2022/5/2
|
||||
# @File Name: test_auth.py
|
||||
|
||||
|
||||
import random
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
|
||||
class TestAuth(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.api = 'http://127.0.0.1:5000/api/v1/'
|
||||
|
||||
@property
|
||||
def r_pwd(self):
|
||||
letters = 'abcdefghijklmnopqrstuvwxyz'
|
||||
r_pwd = ''.join(random.choice(letters) for _ in range(16))
|
||||
return r_pwd
|
||||
|
||||
def test_api_system_header(self):
|
||||
res = requests.post(self.api + 'system', headers={'Authorization': 'bearer unittest'})
|
||||
self.assertEqual(res.status_code, 200)
|
||||
|
||||
def test_api_system_query(self):
|
||||
res = requests.post(self.api + 'system', params={'key': 'unittest'})
|
||||
self.assertEqual(res.status_code, 200)
|
||||
|
||||
def test_api_system_header_failed(self):
|
||||
res = requests.post(self.api + 'system', headers={'Authorization': f'bearer {self.r_pwd}'})
|
||||
self.assertEqual(res.status_code, 403)
|
||||
|
||||
def test_api_system_query_failed(self):
|
||||
res = requests.post(self.api + 'system', params={'key': self.r_pwd})
|
||||
self.assertEqual(res.status_code, 403)
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: Pycharm
|
||||
# @Create Time: 2022/5/1
|
||||
# @File Name: test_count.py
|
||||
|
||||
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
|
||||
class TestCount(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.api = 'http://127.0.0.1:5000/'
|
||||
|
||||
def test_index(self):
|
||||
res = requests.post(self.api).text
|
||||
self.assertIsNotNone(res)
|
||||
|
||||
def test_count(self):
|
||||
res = requests.post(self.api + 'count/test-example').text
|
||||
self.assertIsNotNone(res)
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: Pycharm
|
||||
# @Create Time: 2022/5/1
|
||||
# @File Name: test_resources.py
|
||||
|
||||
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
|
||||
class TestResources(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.resources_urls = {
|
||||
'docs': [
|
||||
'https://request-counter-docs.vercel.app/#/',
|
||||
'https://markusjoe.github.io/RequestCounter/#/'
|
||||
],
|
||||
'database': 'https://filebase.vercel.app/download/data.sqlite',
|
||||
'themes':
|
||||
{
|
||||
'lewd': 'https://static-file-hosting.vercel.app/static/lewd/0',
|
||||
'gelbooru': 'https://static-file-hosting.vercel.app/static/gelbooru/0',
|
||||
'moebooru': 'https://static-file-hosting.vercel.app/static/moebooru/0',
|
||||
'blacked': 'https://static-file-hosting.vercel.app/static/blacked/0',
|
||||
'lisu': 'https://static-file-hosting.vercel.app/static/lisu/0'
|
||||
}
|
||||
}
|
||||
|
||||
def test_doc_vercel(self):
|
||||
res = requests.post(self.resources_urls['docs'][0]).text
|
||||
self.assertIsNotNone(res)
|
||||
|
||||
def test_doc_github(self):
|
||||
res = requests.post(self.resources_urls['docs'][1]).text
|
||||
self.assertIsNotNone(res)
|
||||
|
||||
def test_database(self):
|
||||
res = requests.post(self.resources_urls['database'])
|
||||
self.assertEqual(res.status_code, 200)
|
||||
|
||||
def test_themes(self):
|
||||
for t in self.resources_urls['themes']:
|
||||
res = requests.get(self.resources_urls['themes'][t])
|
||||
self.assertEqual(res.status_code, 200)
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: Pycharm
|
||||
# @Create Time: 2022/5/2
|
||||
# @File Name: test_view.py
|
||||
|
||||
|
||||
import random
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
|
||||
class TestViews(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.api = 'http://127.0.0.1:5000/'
|
||||
|
||||
@property
|
||||
def r_name(self):
|
||||
letters = 'abcdefghijklmnopqrstuvwxyz'
|
||||
r_name = [random.choice(letters) for _ in range(10)]
|
||||
return r_name
|
||||
|
||||
def test_not_found(self):
|
||||
res = requests.get(self.api + 'not_exist_page')
|
||||
self.assertEqual(res.status_code, 404)
|
||||
|
||||
def test_server_internal_error(self):
|
||||
res = requests.get(self.api + f'count/{self.r_name}', params={'length': 0})
|
||||
self.assertEqual(res.status_code, 500)
|
||||
Reference in New Issue
Block a user