def test_classify_resource_raw(self, mock):
        """test classify resource with a known set inserted in the mock"""
        self.init_users(mock)
        self.init_filters(mock)
        self.init_resources(mock)
        classify = ClassifyResources('/fakedir')
        tuple = classify.classify_resource_raw(classify.map.vms, 'region0')
        # Bad region
        self.assertEquals(len(tuple[0]),
                          # community in region1 but not in region0
                          self.count_resources_by_tenant['cpi_4'] +
                          # trial in region1 but not in region0
                          self.count_resources_by_tenant['cpi_5'])
        # Basic + other roles + no role
        self.assertEquals(len(tuple[1]),
                          # basic
                          self.count_resources_by_tenant['cpi_1'] +
                          self.count_resources_by_tenant['cpi_2'] +
                          # other type
                          self.count_resources_by_tenant['cpi_8'] +
                          # unknown type (no role)
                          self.count_resources_by_tenant['cpi_7'] +
                          self.count_resources_by_tenant['cpi_9'])
        # Projects with unknown user
        self.assertEquals(len(tuple[2]),
                          self.count_resources_by_tenant['dpi_1'] +
                          self.count_resources_by_tenant['1000'])

        # Projects with cloudid that does not exists
        self.assertEquals(len(tuple[3]),
                          self.count_resources_by_tenant['fake'])
    def test_classify_resource_raw(self, mock):
        """test classify resource with a known set inserted in the mock"""
        self.init_users(mock)
        self.init_filters(mock)
        self.init_resources(mock)
        classify = ClassifyResources('/fakedir')
        tuple = classify.classify_resource_raw(classify.map.vms, 'region0')
        # Bad region
        self.assertEquals(
            len(tuple[0]),
            # community in region1 but not in region0
            self.count_resources_by_tenant['cpi_4'] +
            # trial in region1 but not in region0
            self.count_resources_by_tenant['cpi_5'])
        # Basic + other roles + no role
        self.assertEquals(
            len(tuple[1]),
            # basic
            self.count_resources_by_tenant['cpi_1'] +
            self.count_resources_by_tenant['cpi_2'] +
            # other type
            self.count_resources_by_tenant['cpi_8'] +
            # unknown type (no role)
            self.count_resources_by_tenant['cpi_7'] +
            self.count_resources_by_tenant['cpi_9'])
        # Projects with unknown user
        self.assertEquals(
            len(tuple[2]), self.count_resources_by_tenant['dpi_1'] +
            self.count_resources_by_tenant['1000'])

        # Projects with cloudid that does not exists
        self.assertEquals(len(tuple[3]),
                          self.count_resources_by_tenant['fake'])
 def test_classify_resource(self, mock):
     """check classify resource, that classify_resource_raw is invoked
     with the right parameters; this is tested comparing the result with
     the VM resources, that must return the same numbers"""
     self.init_users(mock)
     self.init_filters(mock)
     self.init_resources(mock)
     classify = ClassifyResources('/fakedir')
     tuple1 = classify.classify_resource_raw(classify.map.vms, 'region0')
     tuple2 = classify.classify_resource('volumes', 'region0')
     for i in range(4):
         self.assertEquals(len(tuple1[i]), len(tuple2[i]))
 def test_classify_resource(self, mock):
     """check classify resource, that classify_resource_raw is invoked
     with the right parameters; this is tested comparing the result with
     the VM resources, that must return the same numbers"""
     self.init_users(mock)
     self.init_filters(mock)
     self.init_resources(mock)
     classify = ClassifyResources('/fakedir')
     tuple1 = classify.classify_resource_raw(classify.map.vms, 'region0')
     tuple2 = classify.classify_resource('volumes', 'region0')
     for i in range(4):
         self.assertEquals(len(tuple1[i]), len(tuple2[i]))