Beispiel #1
0
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        info_manager = InfoManager.InfoManager()
        info_manager.init_information()
        serverInfoMock = mock()
        tenantInfoMock = mock()
        #mockedQuery = Models.ServerInfo.objects.create(
        #    id=1, owner="Telefonica I+D", version=1.0, runningfrom=datetime.datetime.now(
        #        tz=timezone.get_default_timezone()), doc="test")
        tenantQuery = Models.TenantInfo.objects.create(tenantId="tenantId", windowsize=5)
        when(serverInfoMock).objects().thenReturn(serverInfoMock)
        when(tenantInfoMock).objects().thenReturn(tenantInfoMock)
        #when(serverInfoMock).get(id__exact='1').thenReturn(mockedQuery)
        when(tenantInfoMock).get(tenantId__exact="tenantId").thenReturn(tenantQuery)

        info_manager.setInformations(serverInfoMock, tenantInfoMock)
        myMock = mock()
        mockedInfo = information.information("test", "test", "test", datetime.datetime.now(), "test")
        validWindowSize = "4"
        validWindowSizeValue = 5
        invalidWindowSize = "notValidValue"
        # when(myMock).startingParameters("tenantId").thenReturn(mockedInfo)
        # when(myMock).getVars(myMock).thenReturn(vars(mockedInfo))
        when(myMock).updateWindowSize("tenantId", validWindowSizeValue).thenReturn(mockedInfo)
        when(myMock).updateWindowSize("tenantId", invalidWindowSize).thenReturn(None)

        when(myMock).parse("{\"windowsize\": %s}" % validWindowSize).thenReturn(mockedInfo)
        when(myMock).parse("{\"windowsize\": %s}" % invalidWindowSize).thenReturn(None)
        self.general = GeneralView()
Beispiel #2
0
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        info_manager = InfoManager.InfoManager()
        info_manager.init_information()
        serverInfoMock = mock()
        tenantInfoMock = mock()
        tenantQuery = Models.TenantInfo.objects.create(tenantId="tenantId",
                                                       windowsize=5)
        when(serverInfoMock).objects().thenReturn(serverInfoMock)
        when(tenantInfoMock).objects().thenReturn(tenantInfoMock)
        when(tenantInfoMock).get(
            tenantId__exact="tenantId").thenReturn(tenantQuery)
        info_manager.setInformations(serverInfoMock, tenantInfoMock)
        myMock = mock()
        mockedInfo = information.information("test", "test", "test",
                                             datetime.datetime.now(), "test")
        validWindowSize = "4"
        validWindowSizeValue = 5
        invalidWindowSize = "notValidValue"
        when(myMock).updateWindowSize(
            "tenantId", validWindowSizeValue).thenReturn(mockedInfo)
        when(myMock).updateWindowSize("tenantId",
                                      invalidWindowSize).thenReturn(None)

        when(myMock).parse("{\"windowsize\": %s}" %
                           validWindowSize).thenReturn(mockedInfo)
        when(myMock).parse("{\"windowsize\": %s}" %
                           invalidWindowSize).thenReturn(None)
        self.general = GeneralView()
Beispiel #3
0
 def get_information(self, tenantId):
     """Returns information about the server and tenant's windowsize."""
     serverInfo = self.get_server_information()
     tenantInfo = self.get_tenant_information()
     s_query = serverInfo.objects.get(id__exact='1')
     t_query = tenantInfo.objects.get(tenantId__exact=tenantId)
     owner = s_query.__getattribute__("owner")
     windowsize = t_query.__getattribute__("windowsize")
     version = s_query.__getattribute__("version")
     runningfrom = s_query.__getattribute__("runningfrom")
     doc = s_query.__getattribute__("doc")
     return information.information(owner, windowsize, version, runningfrom, doc)
Beispiel #4
0
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        info_manager = InfoManager.InfoManager()
        info_manager.init_information()
        serverInfoMock = mock()
        tenantInfoMock = mock()
        tenantQuery = Models.TenantInfo.objects.create(tenantId="tenantId", windowsize=5)
        when(serverInfoMock).objects().thenReturn(serverInfoMock)
        when(tenantInfoMock).objects().thenReturn(tenantInfoMock)
        when(tenantInfoMock).get(tenantId__exact="tenantId").thenReturn(tenantQuery)
        info_manager.setInformations(serverInfoMock, tenantInfoMock)
        myMock = mock()
        mockedInfo = information.information("test", "test", "test", datetime.datetime.now(), "test")
        validWindowSize = "4"
        validWindowSizeValue = 5
        invalidWindowSize = "notValidValue"
        when(myMock).updateWindowSize("tenantId", validWindowSizeValue).thenReturn(mockedInfo)
        when(myMock).updateWindowSize("tenantId", invalidWindowSize).thenReturn(None)

        when(myMock).parse("{\"windowsize\": %s}" % validWindowSize).thenReturn(mockedInfo)
        when(myMock).parse("{\"windowsize\": %s}" % invalidWindowSize).thenReturn(None)
        self.general = GeneralView()
Beispiel #5
0
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        info_manager = InfoManager.InfoManager()
        info_manager.init_information()
        serverInfoMock = mock()
        tenantInfoMock = mock()
        #mockedQuery = Models.ServerInfo.objects.create(
        #    id=1, owner="Telefonica I+D", version=1.0, runningfrom=datetime.datetime.now(
        #        tz=timezone.get_default_timezone()), doc="test")
        tenantQuery = Models.TenantInfo.objects.create(tenantId="tenantId",
                                                       windowsize=5)
        when(serverInfoMock).objects().thenReturn(serverInfoMock)
        when(tenantInfoMock).objects().thenReturn(tenantInfoMock)
        #when(serverInfoMock).get(id__exact='1').thenReturn(mockedQuery)
        when(tenantInfoMock).get(
            tenantId__exact="tenantId").thenReturn(tenantQuery)

        info_manager.setInformations(serverInfoMock, tenantInfoMock)
        myMock = mock()
        mockedInfo = information.information("test", "test", "test",
                                             datetime.datetime.now(), "test")
        validWindowSize = "4"
        validWindowSizeValue = 5
        invalidWindowSize = "notValidValue"
        # when(myMock).startingParameters("tenantId").thenReturn(mockedInfo)
        # when(myMock).getVars(myMock).thenReturn(vars(mockedInfo))
        when(myMock).updateWindowSize(
            "tenantId", validWindowSizeValue).thenReturn(mockedInfo)
        when(myMock).updateWindowSize("tenantId",
                                      invalidWindowSize).thenReturn(None)

        when(myMock).parse("{\"windowsize\": %s}" %
                           validWindowSize).thenReturn(mockedInfo)
        when(myMock).parse("{\"windowsize\": %s}" %
                           invalidWindowSize).thenReturn(None)
        self.general = GeneralView()
 def setUp(self):
     self.body1 = "{\"windowsize\": 4}"
     self.expect1 = 4
     self.body2 = "{\"windowsize\": notValidWindowSize}"
     self.info = information.information("test", "test", "test", datetime.datetime.now(), "test")
Beispiel #7
0
 def setUp(self):
     self.body1 = "{\"windowsize\": 4}"
     self.expect1 = 4
     self.body2 = "{\"windowsize\": notValidWindowSize}"
     self.info = information.information("test", "test", "test",
                                         datetime.datetime.now(), "test")