Пример #1
0
 def test_login(self):
     """Test we can login."""
     login = Login(self.username, self.password)
     # Wait until it finished
     while not login.reply.isFinished():
         QCoreApplication.processEvents()
     self.assertIsNotNone(login.get_json_results())
Пример #2
0
 def test_login(self, mock_init):
     """Test we can click OK."""
     mock_init.return_value = None
     organization_project = Login()
     organization_project.get_json_results = MagicMock(
         return_value=(True, self.login_result))
     results = organization_project.get_json_results()
     self.assertTrue(results[0])
     self.assertIsInstance(results[1], dict)
Пример #3
0
    def test_connection_success(self):
        """Test for success test connection"""
        self.dialog.url_input.setText(self.url)
        self.dialog.username_input.setText(self.username)
        self.dialog.password_input.setText(self.password)

        login_api = Login(domain=self.url,
                          username=self.username,
                          password=self.password,
                          on_finished=self.dialog.on_finished)

        login_api.get_json_results = MagicMock(
            return_value={'auth_token': 'token'})

        login_api.connect_post = MagicMock(
            side_effect=login_api.connection_finished())

        self.dialog.call_login_api = MagicMock(return_value=login_api)

        self.assertTrue(self.dialog.save_button.isEnabled())
Пример #4
0
    def login(self):
        """Login function when tools button clicked"""
        username = self.username_input.displayText()
        password = self.password_input.displayText()

        if not username or not password:
            self.msg_bar = QgsMessageBar()
            self.msg_bar.pushWarning("Error", "Username/password is empty.")
        else:
            self.login_button.setEnabled(False)
            self.output_label.setText("logging in....")
            # call tools API
            self.login_api = Login(username, password, self.on_finished)
Пример #5
0
    def call_login_api(self, url, username, password):
        """Call login api.

        :param url: platform url
        :type url: str

        :param username: username for login
        :type username: str

        :param password: password for login
        :type password: str
        """
        return Login(domain=url,
                     username=username,
                     password=password,
                     on_finished=self.on_finished)