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
|
@ -19,7 +19,8 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
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 Js2PyInterpreter
|
||||||
from python_aternos import NodeInterpreter
|
from python_aternos import NodeInterpreter
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
from requests_mock import Mocker
|
from requests_mock import Mocker
|
||||||
|
|
||||||
|
from python_aternos.atconnect import BASE_URL, AJAX_URL
|
||||||
from tests import files
|
from tests import files
|
||||||
|
|
||||||
mock = Mocker()
|
mock = Mocker()
|
||||||
|
|
|
@ -10,19 +10,21 @@ class TestHttp(unittest.TestCase):
|
||||||
|
|
||||||
def test_basic(self) -> None:
|
def test_basic(self) -> None:
|
||||||
with mock.mock:
|
with mock.mock:
|
||||||
at = Client.from_credentials('test', '')
|
Client().login('test', '')
|
||||||
# no exception = ok
|
# no exception = ok
|
||||||
|
|
||||||
def test_servers(self) -> None:
|
def test_servers(self) -> None:
|
||||||
with mock.mock:
|
with mock.mock:
|
||||||
at = Client.from_credentials('test', '')
|
at = Client()
|
||||||
srvs = at.list_servers(cache=False)
|
at.login('test', '')
|
||||||
|
srvs = at.account.list_servers(cache=False)
|
||||||
self.assertTrue(srvs)
|
self.assertTrue(srvs)
|
||||||
|
|
||||||
def test_status(self) -> None:
|
def test_status(self) -> None:
|
||||||
with mock.mock:
|
with mock.mock:
|
||||||
at = Client.from_credentials('test', '')
|
at = Client()
|
||||||
srv = at.list_servers(cache=False)[0]
|
at.login('test', '')
|
||||||
|
srv = at.account.list_servers(cache=False)[0]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
srv.subdomain,
|
srv.subdomain,
|
||||||
'world35v',
|
'world35v',
|
||||||
|
|
|
@ -26,18 +26,18 @@ class TestLogin(unittest.TestCase):
|
||||||
|
|
||||||
def test_auth(self) -> None:
|
def test_auth(self) -> None:
|
||||||
|
|
||||||
self.at = Client.from_credentials(self.user, self.pswd)
|
self.at = Client()
|
||||||
self.assertIsNotNone(self.at)
|
self.at.login(self.user, self.pswd)
|
||||||
|
self.assertTrue(self.at.atconn.atcookie)
|
||||||
|
|
||||||
def test_servers(self) -> None:
|
def test_servers(self) -> None:
|
||||||
|
|
||||||
if self.at is None:
|
if self.at is None:
|
||||||
self.at = Client.from_credentials(
|
self.at = Client()
|
||||||
self.user, self.pswd
|
self.at.login(self.user, self.pswd)
|
||||||
)
|
|
||||||
|
|
||||||
srvs = len(
|
srvs = len(
|
||||||
self.at.list_servers(
|
self.at.account.list_servers(
|
||||||
cache=False
|
cache=False
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -46,9 +46,8 @@ class TestLogin(unittest.TestCase):
|
||||||
def test_logout(self) -> None:
|
def test_logout(self) -> None:
|
||||||
|
|
||||||
if self.at is None:
|
if self.at is None:
|
||||||
self.at = Client.from_credentials(
|
self.at = Client()
|
||||||
self.user, self.pswd
|
self.at.login(self.user, self.pswd)
|
||||||
)
|
|
||||||
|
|
||||||
self.at.logout()
|
self.at.logout()
|
||||||
|
|
||||||
|
|
Reference in a new issue