def test_setters(self): """ Test setters """ w = QgsAuthSettingsWidget() w.setUsername('username') self.assertFalse(w.configurationTabIsSelected()) self.assertEqual(w.username(), 'username') w = QgsAuthSettingsWidget() w.setPassword('password') self.assertEqual(w.password(), 'password') self.assertFalse(w.configurationTabIsSelected()) w = QgsAuthSettingsWidget() w.setConfigId(self.auth_config.id()) self.assertEqual(w.configId(), self.auth_config.id()) self.assertTrue(w.configurationTabIsSelected()) w = QgsAuthSettingsWidget() w.setUsername('username') w.setPassword('password') w.setConfigId(self.auth_config.id()) self.assertEqual(w.configId(), self.auth_config.id()) self.assertTrue(w.configurationTabIsSelected()) w = QgsAuthSettingsWidget() w.setDataprovider('db2') self.assertEqual(w.dataprovider(), 'db2')
def testConvertToEncrypted(self): """ Test the widget to encrypted conversion """ w = QgsAuthSettingsWidget(None, None, 'username', 'password') self.assertEqual(w.username(), 'username') self.assertEqual(w.password(), 'password') self.assertEqual(w.configId(), '') self.assertFalse(w.configurationTabIsSelected()) self.assertTrue(w.btnConvertToEncryptedIsEnabled()) self.assertTrue(w.convertToEncrypted()) self.assertNotEqual(w.configId(), '') self.assertEqual(w.username(), '') self.assertEqual(w.password(), '') self.assertTrue(w.configurationTabIsSelected()) self.assertFalse(w.btnConvertToEncryptedIsEnabled())
def testWidgetUsername(self): """ Test the widget with username only """ w = QgsAuthSettingsWidget(None, None, 'username') self.assertEqual(w.username(), 'username') self.assertEqual(w.password(), '') self.assertEqual(w.configId(), '') self.assertFalse(w.configurationTabIsSelected())
def testWidgetConfigId(self): """ Test the widget with configId """ w = QgsAuthSettingsWidget(None, self.auth_config.id()) self.assertEqual(w.username(), '') self.assertEqual(w.password(), '') self.assertEqual(w.configId(), self.auth_config.id()) self.assertTrue(w.configurationTabIsSelected()) self.assertFalse(w.btnConvertToEncryptedIsEnabled())
def testWidgetNoArgs(self): """ Test the widget with no args """ w = QgsAuthSettingsWidget() self.assertEqual(w.username(), '') self.assertEqual(w.password(), '') self.assertEqual(w.configId(), '') self.assertTrue(w.configurationTabIsSelected()) self.assertFalse(w.btnConvertToEncryptedIsEnabled())
def testWidgetUsernameAndPassword(self): """ Test the widget with username and password """ w = QgsAuthSettingsWidget(None, None, 'username', 'password') self.assertEqual(w.username(), 'username') self.assertEqual(w.password(), 'password') self.assertEqual(w.configId(), '') self.assertFalse(w.configurationTabIsSelected()) self.assertTrue(w.btnConvertToEncryptedIsEnabled())