Rewritten tests repsectively (see the prev. commit)
This commit is contained in:
parent
29866f0446
commit
b734f5df93
5 changed files with 23 additions and 19 deletions
|
@ -27,6 +27,6 @@ def read_html(name: str) -> bytes:
|
|||
|
||||
if not path.exists():
|
||||
return b''
|
||||
|
||||
|
||||
with path.open('rb') as file:
|
||||
return file.read()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from requests_mock import Mocker
|
||||
|
||||
from python_aternos.atconnect import BASE_URL, AJAX_URL
|
||||
from tests import files
|
||||
|
||||
mock = Mocker()
|
||||
|
|
|
@ -7,22 +7,24 @@ from tests import mock
|
|||
|
||||
|
||||
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',
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Reference in a new issue