示例#1
0
    def test_ParameterDefaultsAreSetCorrectly(self):
        """
        Verifies requirements GEN000003 and GEN000004. Check that the default 
        optional parameters are set when none are specified. 
        
        GEN000003: Komodo shall provide a context to capture command line 
        options for the following attributes: External, Implantable, Environment,
        Browser Type, Enroll type, PG Simulator, Debug.

        
        GEN000004: Komodo shall provide the ability to load the product line 
        model for the external and implantable in the context.
        """
        # Setup Mock Object
        self.common.SetupMox(self)

        testharness.getOptDebugFlag().AndReturn(True)
        testharness.getOptParam().AndReturn(None)
        testharness.getOptExternal().AndReturn(self.external)
        testharness.getOptImplantable().AndReturn(self.implantable)
        testharness.getOptEnv().AndReturn(self.env)

        # In order for the testContext to return successfully, the environment 
        # geography and the external availability should match. Force this to 
        # occur with a mock environment object
        MockEnv = mox.MockObject(Environment)
        MockEnv.geography = 'us'
        availability.evaluate('US').AndReturn(True)
        environment.getInstance(self.env).AndReturn(MockEnv)
        self.mocker.ReplayAll()

        testContext = komodo.getTestContext()

        self.trace('GEN000003')
        self.verifyEqual(testContext['brwsr'], komodo.BROWSER_DEFAULT)
        self.verifyEqual(testContext['pgsim'], False)
        self.verifyEqual(testContext['enroll'], True)
        self.mocker.VerifyAll()
        
        # Reset Mock Object
        self.common.UnsetMox(self)	 
        
        self.trace('GEN000004')
        self.verifyTrue(availability.getExternal() is not None, msg="External PLM was loaded.")
        self.verifyTrue(availability.getImplantable() is not None, msg="Implantable PLM was loaded.")
示例#2
0
    def REQ009(self):
        self.trace("REQ009")

        # Test with default values for the entity
        defaultPG = self.dataFactory.createPG()
        self.verifyEqual(defaultPG.modelNumber, self.context["implantable"], msg="modelNumber")
        self.verifyTrue(defaultPG.serialNumber, msg="serialNumber")
        self.verifyTrue(defaultPG.rfCenterFrequency, msg="rfCenterFrequency")
        self.verifyTrue(defaultPG.wakeUpAccessCode, msg="wakeUpAccessCode")
        self.verifyTrue(defaultPG.systemBOLTimeStamp, msg="systemBOLTimeStamp")
        self.verifyTrue(isinstance(defaultPG.systemBOLTimeStamp, datetime.datetime), msg="systemBOLTimeStamp type")
        self.verifyTrue(defaultPG.implantDate, msg="implantDate")
        self.verifyTrue(isinstance(defaultPG.implantDate, datetime.date), msg="implantDate type")

        # Test with specific values given to the entity
        model = getImplantable()
        serial = komodors.utils.generateSerialNumber()
        rfCenterFrequency = 1234567890
        wakeUpAccessCode = 12345

        specificPG = self.dataFactory.createPG(serial, model, wakeUpAccessCode, rfCenterFrequency)

        self.verifyEqual(specificPG.modelNumber, model, msg="modelNumber")
        self.verifyEqual(specificPG.serialNumber, serial, msg="serialNumber")
        self.verifyEqual(specificPG.rfCenterFrequency, str(rfCenterFrequency), msg="rfCenterFrequency")
        self.verifyEqual(specificPG.wakeUpAccessCode, str(wakeUpAccessCode), msg="wakeUpAccessCode")
        self.verifyTrue(specificPG.systemBOLTimeStamp, msg="systemBOLTimeStamp")
        self.verifyTrue(isinstance(specificPG.systemBOLTimeStamp, datetime.datetime), msg="systemBOLTimeStamp type")
        self.verifyTrue(specificPG.implantDate, msg="implantDate")
        self.verifyTrue(isinstance(specificPG.implantDate, datetime.date), msg="implantDate type")

        # Test raising IncompatibleModelError
        badModel = "ABC-XYZ-0"
        try:
            badModelPG = self.dataFactory.createPG(modelNbr=badModel)
        except IncompatibleModelError:
            self.verified(msg="IncompatibleModelError raised for model = %s" % badModel)
        except Exception as e:
            self.verifyFailed(e)

        # Fix the PLM back to the original for other tests that may be running.
        loadImplantable(self.context["implantable"])
示例#3
0
    def __init__(
        self,
        model=None,
        serial=None,
        rfCenterFrequency=None,
        wakeUpAccessCode=None,
        systemBOLTimeStamp=datetime.datetime.now(),
        implantDate=datetime.date.today(),
    ):
        """
        This is the constructor which initializes attributes of PGEntity class
        
        @type model: C{str}
        @param model: Model Number of PG (Required).
        
        @type serial: C{str}
        @param serial: Serial Number of PG. A random seven digit number is 
                       generated if none is provided.
                              
        @type rfCenterFrequency: C{str}
        @param rfCenterFrequency: RF Center Frequency of PG.
                                  Defaults to Band-specific frequencies in the 
                                  komodors.ini file.
        
        @type wakeUpAccessCode: C{str}
        @param wakeUpAccessCode: Wake-up Access code of PG. Defaults to '10002'.
        
        @type systemBOLTimeStamp: C{datetime.datetime}
        @param systemBOLTimeStamp: Begining of life timestamp of PG.
                                   Defaults to current date/time (i.e. now).
        
        @type implantDate: C{datetime.date}
        @param implantDate: Implant Date of PG. Defaults to today's date.
        """
        if model is None:
            model = getImplantable()

        if serial is None:
            serial = generateSerialNumber()

        super(PGEntity, self).__init__(model, serial)

        if wakeUpAccessCode is not None:
            self._wakeUpAccessCode = str(wakeUpAccessCode)
        else:
            self._wakeUpAccessCode = perseus.config.getProperty("wakeupAccessCode", "PG", "10002")

        if rfCenterFrequency:
            self._rfCenterFrequency = str(rfCenterFrequency)
        else:
            self._rfCenterFrequency = self._getBandSpecificCenterFrequency()

        if isinstance(systemBOLTimeStamp, datetime.datetime):
            self._systemBOLTimeStamp = systemBOLTimeStamp
        else:
            raise TypeError("systemBOLTimeStamp must be a datetime.datetime object")

        if isinstance(implantDate, datetime.date):
            self._implantDate = implantDate
        else:
            raise TypeError("implantDate must be a datetime.date object")

        logger.info("Created a PG with model = %s and serial = %s" % (self.modelNumber, self.serialNumber))