def test_ip4_address_invalid(self):
        """
        Test IPv4 address invalid
        """
        # WHEN: Test with a local loopback test
        valid = verify_ip_address(addr=ip4_bad)

        # THEN: Verify we received True
        self.assertFalse(valid, 'Bad IPv4 address should not have been valid')
    def test_ip6_loopback_valid(self):
        """
        Test IPv6 loopback valid
        """
        # WHEN: Test IPv6 loopback address
        valid = verify_ip_address(addr=ip6_loopback)

        # THEN: Validate return
        self.assertTrue(valid, 'IPv6 loopback address should have been valid')
    def test_ip6_address_invalid(self):
        """
        Test NetworkUtils IPv6 address invalid
        """
        # WHEN: Given an invalid IPv6 address
        valid = verify_ip_address(addr=ip6_bad)

        # THEN: Validate bad return
        self.assertFalse(valid, 'IPv6 bad address should have been invalid')
    def test_ip4_broadcast_valid(self):
        """
        Test IPv4 broadcast valid
        """
        # WHEN: Test with a local loopback test
        valid = verify_ip_address(addr=ip4_broadcast)

        # THEN: Verify we received True
        self.assertTrue(valid, 'IPv4 broadcast address should have been valid')
Beispiel #5
0
    def test_ip6_loopback_valid(self):
        """
        Test IPv6 loopback valid
        """
        # WHEN: Test IPv6 loopback address
        valid = verify_ip_address(addr=ip6_loopback)

        # THEN: Validate return
        self.assertTrue(valid, 'IPv6 loopback address should have been valid')
    def test_ip6_local_valid(self):
        """
        Test IPv6 link-local valid
        """
        # WHEN: Test IPv6 link-local address
        valid = verify_ip_address(addr=ip6_link_local)

        # THEN: Validate return
        self.assertTrue(valid, 'IPv6 link-local address should have been valid')
Beispiel #7
0
    def test_ip4_address_invalid(self):
        """
        Test IPv4 address invalid
        """
        # WHEN: Test with a local loopback test
        valid = verify_ip_address(addr=ip4_bad)

        # THEN: Verify we received True
        self.assertFalse(valid, 'Bad IPv4 address should not have been valid')
Beispiel #8
0
    def test_ip4_broadcast_valid(self):
        """
        Test IPv4 broadcast valid
        """
        # WHEN: Test with a local loopback test
        valid = verify_ip_address(addr=ip4_broadcast)

        # THEN: Verify we received True
        self.assertTrue(valid, 'IPv4 broadcast address should have been valid')
Beispiel #9
0
    def test_ip6_address_invalid(self):
        """
        Test NetworkUtils IPv6 address invalid
        """
        # WHEN: Given an invalid IPv6 address
        valid = verify_ip_address(addr=ip6_bad)

        # THEN: Validate bad return
        self.assertFalse(valid, 'IPv6 bad address should have been invalid')
    def test_ip6_local_valid(self):
        """
        Test IPv6 link-local valid
        """
        # WHEN: Test IPv6 link-local address
        valid = verify_ip_address(addr=ip6_link_local)

        # THEN: Validate return
        assert valid is True, 'IPv6 link-local address should have been valid'
    def test_ip4_local_valid(self):
        """
        Test IPv4 local valid
        """
        # WHEN: Test with a local loopback test
        valid = verify_ip_address(addr=ip4_local)

        # THEN: Verify we received True
        assert valid is True, 'IPv4 local address should have been valid'
Beispiel #12
0
 def accept_me(self):
     """
     Validate input before accepting input.
     """
     log.debug('accept_me() signal received')
     if len(self.name_text.text().strip()) < 1:
         QtGui.QMessageBox.warning(
             self, translate('OpenLP.ProjectorEdit', 'Name Not Set'),
             translate(
                 'OpenLP.ProjectorEdit',
                 'You must enter a name for this entry.<br />'
                 'Please enter a new name for this entry.'))
         valid = False
         return
     name = self.name_text.text().strip()
     record = self.projectordb.get_projector_by_name(name)
     if record is not None and record.id != self.projector.id:
         QtGui.QMessageBox.warning(
             self, translate('OpenLP.ProjectorEdit', 'Duplicate Name'),
             translate(
                 'OpenLP.ProjectorEdit',
                 'There is already an entry with name "%s" in '
                 'the database as ID "%s". <br />'
                 'Please enter a different name.' % (name, record.id)))
         valid = False
         return
     adx = self.ip_text.text()
     valid = verify_ip_address(adx)
     if valid:
         ip = self.projectordb.get_projector_by_ip(adx)
         if ip is None:
             valid = True
             self.new_projector = True
         elif ip.id != self.projector.id:
             QtGui.QMessageBox.warning(
                 self,
                 translate('OpenLP.ProjectorWizard',
                           'Duplicate IP Address'),
                 translate(
                     'OpenLP.ProjectorWizard',
                     'IP address "%s"<br />is already in the database as ID %s.'
                     '<br /><br />Please Enter a different IP address.' %
                     (adx, ip.id)))
             valid = False
             return
     else:
         QtGui.QMessageBox.warning(
             self, translate('OpenLP.ProjectorWizard',
                             'Invalid IP Address'),
             translate(
                 'OpenLP.ProjectorWizard',
                 'IP address "%s"<br>is not a valid IP address.'
                 '<br /><br />Please enter a valid IP address.' % adx))
         valid = False
         return
     port = int(self.port_text.text())
     if port < 1000 or port > 32767:
         QtGui.QMessageBox.warning(
             self, translate('OpenLP.ProjectorWizard',
                             'Invalid Port Number'),
             translate(
                 'OpenLP.ProjectorWizard',
                 'Port numbers below 1000 are reserved for admin use only, '
                 '<br />and port numbers above 32767 are not currently usable.'
                 '<br /><br />Please enter a valid port number between '
                 ' 1000 and 32767.'
                 '<br /><br />Default PJLink port is %s' % PJLINK_PORT))
         valid = False
     if valid:
         self.projector.ip = self.ip_text.text()
         self.projector.pin = self.pin_text.text()
         self.projector.port = int(self.port_text.text())
         self.projector.name = self.name_text.text()
         self.projector.location = self.location_text.text()
         self.projector.notes = self.notes_text.toPlainText()
         if self.new_projector:
             saved = self.projectordb.add_projector(self.projector)
         else:
             saved = self.projectordb.update_projector(self.projector)
         if not saved:
             QtGui.QMessageBox.warning(
                 self,
                 translate('OpenLP.ProjectorEditForm', 'Database Error'),
                 translate(
                     'OpenLP.ProjectorEditForm',
                     'There was an error saving projector '
                     'information. See the log for the error'))
             return saved
         if self.new_projector:
             self.newProjector.emit(adx)
         else:
             self.editProjector.emit(self.projector)
         self.close()
Beispiel #13
0
 def accept_me(self):
     """
     Validate input before accepting input.
     """
     log.debug('accept_me() signal received')
     if len(self.name_text.text().strip()) < 1:
         QtWidgets.QMessageBox.warning(self,
                                       translate('OpenLP.ProjectorEdit', 'Name Not Set'),
                                       translate('OpenLP.ProjectorEdit',
                                                 'You must enter a name for this entry.<br />'
                                                 'Please enter a new name for this entry.'))
         valid = False
         return
     name = self.name_text.text().strip()
     record = self.projectordb.get_projector_by_name(name)
     if record is not None and record.id != self.projector.id:
         QtWidgets.QMessageBox.warning(self,
                                       translate('OpenLP.ProjectorEdit', 'Duplicate Name'),
                                       translate('OpenLP.ProjectorEdit',
                                                 'There is already an entry with name "{name}" in '
                                                 'the database as ID "{record}". <br />'
                                                 'Please enter a different name.'.format(name=name,
                                                                                         record=record.id)))
         valid = False
         return
     adx = self.ip_text.text()
     valid = verify_ip_address(adx)
     if valid:
         ip = self.projectordb.get_projector_by_ip(adx)
         if ip is None:
             valid = True
             self.new_projector = True
         elif ip.id != self.projector.id:
             QtWidgets.QMessageBox.warning(self,
                                           translate('OpenLP.ProjectorWizard', 'Duplicate IP Address'),
                                           translate('OpenLP.ProjectorWizard',
                                                     'IP address "{ip}"<br />is already in the database '
                                                     'as ID {data}.<br /><br />Please Enter a different '
                                                     'IP address.'.format(ip=adx, data=ip.id)))
             valid = False
             return
     else:
         QtWidgets.QMessageBox.warning(self,
                                       translate('OpenLP.ProjectorWizard', 'Invalid IP Address'),
                                       translate('OpenLP.ProjectorWizard',
                                                 'IP address "{ip}"<br>is not a valid IP address.'
                                                 '<br /><br />Please enter a valid IP address.'.format(ip=adx)))
         valid = False
         return
     port = int(self.port_text.text())
     if port < 1000 or port > 32767:
         QtWidgets.QMessageBox.warning(self,
                                       translate('OpenLP.ProjectorWizard', 'Invalid Port Number'),
                                       translate('OpenLP.ProjectorWizard',
                                                 'Port numbers below 1000 are reserved for admin use only, '
                                                 '<br />and port numbers above 32767 are not currently usable.'
                                                 '<br /><br />Please enter a valid port number between '
                                                 '1000 and 32767.<br /><br />'
                                                 'Default PJLink port is {port}'.format(port=PJLINK_PORT)))
         valid = False
     if valid:
         self.projector.ip = self.ip_text.text()
         self.projector.pin = self.pin_text.text()
         self.projector.port = int(self.port_text.text())
         self.projector.name = self.name_text.text()
         self.projector.location = self.location_text.text()
         self.projector.notes = self.notes_text.toPlainText()
         if self.new_projector:
             saved = self.projectordb.add_projector(self.projector)
         else:
             saved = self.projectordb.update_projector(self.projector)
         if not saved:
             QtWidgets.QMessageBox.warning(self,
                                           translate('OpenLP.ProjectorEditForm', 'Database Error'),
                                           translate('OpenLP.ProjectorEditForm',
                                                     'There was an error saving projector '
                                                     'information. See the log for the error'))
             return saved
         if self.new_projector:
             self.newProjector.emit(adx)
         else:
             self.editProjector.emit(self.projector)
         self.close()