def test_args_vid_not_empty(self):
     """
     checks to make sure that the is_serial_usb function
     exists correctly when the args["vid"] is not empty
     and port["vid"] doesn't equal args["vid"]
     """
     port = ListPortInfo()
     port.vid = "foo"
     args = Namespace()
     args.vid = "bar"
     response = is_usb_serial(port, args)
     self.assertFalse(response)
    def test_port_vid_empty(self):
        """
        insures that the is_serial_usb function retunrs false
        if the port.vid param is empty
        """
        port = ListPortInfo()
        port.vid = None
        args = Namespace()
        args.vid = None

        response = is_usb_serial(port, args)
        self.assertFalse(response)
    def test_args_vendor_not_empty(self):
        """
        checks to make sure that the is_serial_usb function
        exists correctly when the args["vendor"] is not empty
        and port["manufacturer"] doesn't start with args["vendor"]
        """
        port, args = ListPortInfo(), Namespace()
        port.vid = "bar"
        port.pid = "foo"
        port.manufacturer = "Apple"

        args.vid = None
        args.pid = None
        args.vendor = "Microsoft"

        response = is_usb_serial(port, args)
        self.assertFalse(response)
    def test_pass(self):
        """
        insure that is_serial_usb returns true if all test cases haven't
        failed
        """
        port, args = ListPortInfo(), Namespace()

        port.vid = "bar"
        port.pid = "foo"
        port.manufacturer = "Apple"
        port.serial_number = "456"
        port.interface = "bar"

        args.vid = None
        args.pid = None
        args.vendor = None
        args.serial = None
        args.intf = None

        response = is_usb_serial(port, args)
        self.assertTrue(response)
    def test_args_intf_not_empty(self):
        """
        checks to make sure that the is_serial_usb function
        exists correctly when the args["serial"] is not empty
        and port["interface"] is none
        """
        port, args = ListPortInfo(), Namespace()

        port.vid = "bar"
        port.pid = "foo"
        port.manufacturer = "Apple"
        port.serial_number = "456"
        port.interface = None

        args.vid = None
        args.pid = None
        args.vendor = None
        args.serial = None
        args.intf = "foo"

        response = is_usb_serial(port, args)
        self.assertFalse(response)