def test_empty_init(self, getpwd, genuid): """Test initialization with no params.""" auth = Auth() self.assertDictEqual(auth.data, {}) getpwd.return_value = "bar" genuid.return_value = 1234 with mock.patch("builtins.input", return_value="foo"): auth.validate_login() expected_data = { "username": "******", "password": "******", "uid": 1234, "device_id": const.DEVICE_ID, } self.assertDictEqual(auth.data, expected_data)
def test_barebones_init(self, getpwd, genuid): """Test basebones initialization.""" login_data = {"username": "******", "password": "******"} auth = Auth(login_data) self.assertDictEqual(auth.data, login_data) getpwd.return_value = "bar" genuid.return_value = 1234 with mock.patch("builtins.input", return_value="foo"): auth.validate_login() expected_data = { "username": "******", "password": "******", "uid": 1234, "device_id": const.DEVICE_ID, } self.assertDictEqual(auth.data, expected_data)
def test_full_init(self): """Test full initialization.""" login_data = { "username": "******", "password": "******", "token": "token", "host": "host", "region_id": "region_id", "client_id": "client_id", "account_id": "account_id", "uid": 1234, "notification_key": 4321, "device_id": "device_id", } auth = Auth(login_data) self.assertEqual(auth.token, "token") self.assertEqual(auth.host, "host") self.assertEqual(auth.region_id, "region_id") self.assertEqual(auth.client_id, "client_id") self.assertEqual(auth.account_id, "account_id") auth.validate_login() self.assertDictEqual(auth.login_attributes, login_data)