Rewritten tests repsectively (see the prev. commit)

This commit is contained in:
DarkCat09 2023-05-24 20:04:42 +04:00
parent 29866f0446
commit b734f5df93
5 changed files with 23 additions and 19 deletions

View file

@ -19,7 +19,8 @@
import re
import sys
from python_aternos import AternosConnect
from python_aternos.atconnect import AternosConnect
from python_aternos.atconnect import BASE_URL
from python_aternos import Js2PyInterpreter
from python_aternos import NodeInterpreter

View file

@ -1,4 +1,6 @@
from requests_mock import Mocker
from python_aternos.atconnect import BASE_URL, AJAX_URL
from tests import files
mock = Mocker()

View file

@ -10,19 +10,21 @@ class TestHttp(unittest.TestCase):
def test_basic(self) -> None:
with mock.mock:
at = Client.from_credentials('test', '')
Client().login('test', '')
# no exception = ok
def test_servers(self) -> None:
with mock.mock:
at = Client.from_credentials('test', '')
srvs = at.list_servers(cache=False)
at = Client()
at.login('test', '')
srvs = at.account.list_servers(cache=False)
self.assertTrue(srvs)
def test_status(self) -> None:
with mock.mock:
at = Client.from_credentials('test', '')
srv = at.list_servers(cache=False)[0]
at = Client()
at.login('test', '')
srv = at.account.list_servers(cache=False)[0]
self.assertEqual(
srv.subdomain,
'world35v',

View file

@ -26,18 +26,18 @@ class TestLogin(unittest.TestCase):
def test_auth(self) -> None:
self.at = Client.from_credentials(self.user, self.pswd)
self.assertIsNotNone(self.at)
self.at = Client()
self.at.login(self.user, self.pswd)
self.assertTrue(self.at.atconn.atcookie)
def test_servers(self) -> None:
if self.at is None:
self.at = Client.from_credentials(
self.user, self.pswd
)
self.at = Client()
self.at.login(self.user, self.pswd)
srvs = len(
self.at.list_servers(
self.at.account.list_servers(
cache=False
)
)
@ -46,9 +46,8 @@ class TestLogin(unittest.TestCase):
def test_logout(self) -> None:
if self.at is None:
self.at = Client.from_credentials(
self.user, self.pswd
)
self.at = Client()
self.at.login(self.user, self.pswd)
self.at.logout()