-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
731c237
commit 3adf475
Showing
9 changed files
with
154 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from side import Client, Server | ||
from utils import ServerDB | ||
from .side import Client, Server | ||
from .utils import ServerDB | ||
|
||
__all__ = ["Client", "Server", "ServerDB"] | ||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import unittest | ||
from pathlib import Path | ||
from DMBotNetwork.utils.server_db import ServerDB | ||
|
||
class TestServerDB(unittest.IsolatedAsyncioTestCase): | ||
async def asyncSetUp(self): | ||
self.temp_db_file: Path = Path("temp") | ||
self.temp_db_file.mkdir(exist_ok=True) | ||
ServerDB.set_db_path(self.temp_db_file) | ||
await ServerDB.start() | ||
|
||
async def asyncTearDown(self): | ||
await ServerDB.stop() | ||
db_file = self.temp_db_file / "server.db" | ||
if db_file.exists(): | ||
db_file.unlink() | ||
if self.temp_db_file.exists(): | ||
self.temp_db_file.rmdir() | ||
|
||
async def test_add_user(self): | ||
await ServerDB.add_user("test_user", "password") | ||
self.assertIn("test_user", ServerDB._exist_user) | ||
await ServerDB.delete_user("test_user") | ||
|
||
async def test_delete_user(self): | ||
await ServerDB.add_user("test_user", "password") | ||
await ServerDB.delete_user("test_user") | ||
self.assertNotIn("test_user", ServerDB._exist_user) | ||
|
||
async def test_change_user_password(self): | ||
await ServerDB.add_user("test_user", "password") | ||
await ServerDB.change_user_password("test_user", "new_password") | ||
login = await ServerDB.login_user('test_user', 'new_password') | ||
self.assertEqual(login, 'test_user') | ||
await ServerDB.delete_user("test_user") | ||
|
||
async def test_get_access(self): | ||
await ServerDB.add_user("test_user", "password", {"some_access": True}) | ||
access = await ServerDB.get_access("test_user") | ||
self.assertEqual(access, {"some_access": True}) | ||
await ServerDB.delete_user("test_user") | ||
|
||
async def test_login_user(self): | ||
await ServerDB.add_user("test_user", "password") | ||
result = await ServerDB.login_user("test_user", "password") | ||
self.assertEqual(result, "test_user") | ||
await ServerDB.delete_user("test_user") | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
# bruh | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
name="DMBotNetwork", | ||
version="0.1.0", | ||
packages=find_packages(), | ||
install_requires=['aiosqlite', 'bcrypt', 'msgpack'], | ||
install_requires=["aiosqlite", "bcrypt", "msgpack"], | ||
author="Angels And Demons dev team", | ||
author_email="[email protected]", | ||
description="Нэткод для проектов DMBot", | ||
|
@@ -16,6 +16,6 @@ | |
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | ||
"Operating System :: OS Independent", | ||
], | ||
python_requires='>=3.11', | ||
python_requires=">=3.11", | ||
license="GPL-3.0", | ||
) |