1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-05-15 23:00:18 -07:00
wideq/tests/test_core.py
2021-03-22 16:08:01 -03:00

62 lines
2.2 KiB
Python

import unittest
import responses
import wideq.core
class SimpleTest(unittest.TestCase):
@responses.activate
def test_gateway_en_US(self):
responses.add(
responses.GET,
"https://route.lgthinq.com:46030/v1/service/application/gateway-uri",
json={
"result": {
"thinq1Uri": "https://aic.lgthinq.com:46030/api",
"thinq2Uri": "https://aic-service.lgthinq.com:46030/v1",
"empUri": "https://us.m.lgaccount.com",
"countryCode": "US",
"langCode": "en-US",
}
},
)
gatewayInstance = wideq.core.Gateway.discover("US", "en-US")
self.assertEqual(len(responses.calls), 1)
self.assertEqual(gatewayInstance.country, "US")
self.assertEqual(gatewayInstance.language, "en-US")
self.assertEqual(
gatewayInstance.auth_base, "https://us.m.lgaccount.com"
)
self.assertEqual(
gatewayInstance.api_root,
"https://aic-service.lgthinq.com:46030/v1",
)
@responses.activate
def test_gateway_en_NO(self):
responses.add(
responses.GET,
"https://route.lgthinq.com:46030/v1/service/application/gateway-uri",
json={
"result": {
"countryCode": "NO",
"langCode": "en-NO",
"thinq1Uri": "https://eic.lgthinq.com:46030/api",
"thinq2Uri": "https://eic-service.lgthinq.com:46030/v1",
"empUri": "https://no.m.lgaccount.com",
"oauthUri": "https://no.lgeapi.com",
}
},
)
gatewayInstance = wideq.core.Gateway.discover("NO", "en-NO")
self.assertEqual(len(responses.calls), 1)
self.assertEqual(gatewayInstance.country, "NO")
self.assertEqual(gatewayInstance.language, "en-NO")
self.assertEqual(
gatewayInstance.auth_base, "https://no.m.lgaccount.com"
)
self.assertEqual(
gatewayInstance.api_root,
"https://eic-service.lgthinq.com:46030/v1",
)