2020-04-02 15:08:14 +02:00
|
|
|
from phpTest import PhpTest
|
|
|
|
|
|
|
|
class ApiTestCase(PhpTest):
|
|
|
|
|
|
|
|
def __init__(self):
|
2020-04-02 16:16:58 +02:00
|
|
|
super().__init__({
|
|
|
|
"Testing login…": self.test_login,
|
|
|
|
"Testing already logged in…": self.test_already_logged_in,
|
|
|
|
"Testing get api keys empty…": self.test_get_api_keys,
|
|
|
|
})
|
2020-04-02 15:08:14 +02:00
|
|
|
|
|
|
|
def api(self, method):
|
2020-04-02 16:16:58 +02:00
|
|
|
return "/api/%s" % method
|
|
|
|
|
|
|
|
def test_login(self):
|
|
|
|
obj = self.httpPost(self.api("login"), data={ "username": PhpTest.ADMIN_USERNAME, "password": PhpTest.ADMIN_PASSWORD })
|
|
|
|
self.assertEquals(True, obj["success"], obj["msg"])
|
|
|
|
return obj
|
2020-04-02 15:08:14 +02:00
|
|
|
|
2020-04-02 16:16:58 +02:00
|
|
|
def test_already_logged_in(self):
|
|
|
|
obj = self.test_login()
|
|
|
|
self.assertEquals("You are already logged in", obj["msg"])
|
2020-04-02 15:08:14 +02:00
|
|
|
|
2020-04-02 16:16:58 +02:00
|
|
|
def test_get_api_keys(self):
|
|
|
|
obj = self.httpPost(self.api("getApiKeys"))
|
2020-04-02 15:08:14 +02:00
|
|
|
self.assertEquals(True, obj["success"], obj["msg"])
|
2020-04-02 16:16:58 +02:00
|
|
|
self.assertEquals([], obj["api_keys"])
|
|
|
|
return obj
|