def test_filter_overlap_sorter_without_valid(self):
        product1 = "Test Product 1"
        provided1 = "Provided By Test Product 1"
        product2 = "Test Product 2"
        provided2 = "Provided By Test Product 2"

        cert_start = datetime.now() - timedelta(days=10)
        cert_end = datetime.now() + timedelta(days=365)
        cert1 = StubProductCertificate(StubProduct(provided1),
                                                   start_date=cert_start,
                                                   end_date=cert_end)

        ent_dir = StubCertificateDirectory([cert1])
        mock_sorter = Mock()
        mock_sorter.valid_products = {}
        pool_filter = PoolFilter(product_dir=StubCertificateDirectory([]),
                entitlement_dir=ent_dir,
                sorter=mock_sorter)

        pools = [
                create_pool(product1, product1, provided_products=[provided1],
                            start_end_range=DateRange(cert_start, cert_end)),
                create_pool(product2, product2, provided_products=[provided2],
                            start_end_range=DateRange(cert_start, cert_end))
        ]
        result = pool_filter.filter_out_overlapping(pools)
        self.assertEquals([pools[0], pools[1]], result)

        result = pool_filter.filter_out_non_overlapping(pools)
        self.assertEquals([], result)
    def test_filter_no_overlap_with_future_entitlement(self):
        product1 = "Test Product 1"
        provided1 = "Provided By Test Product 1"

        cert_start = datetime.now() + timedelta(days=365)
        cert_end = cert_start + timedelta(days=365)
        cert1 = StubProductCertificate(StubProduct(provided1),
                                                   start_date=cert_start,
                                                   end_date=cert_end)

        ent_dir = StubCertificateDirectory([cert1])
        pool_filter = PoolFilter(product_dir=StubCertificateDirectory([]),
                entitlement_dir=ent_dir)

        begin_date = datetime.now() - timedelta(days=100)
        end_date = datetime.now() + timedelta(days=100)
        pools = [
                create_pool(product1, product1, provided_products=[provided1],
                            start_end_range=DateRange(begin_date, end_date)),
        ]
        result = pool_filter.filter_out_overlapping(pools)
        self.assertEquals(1, len(result))

        result = pool_filter.filter_out_non_overlapping(pools)
        self.assertEquals(0, len(result))
Beispiel #3
0
    def test_filter_no_overlap_with_future_entitlement(self):
        product1 = "Test Product 1"
        provided1 = "Provided By Test Product 1"

        cert_start = datetime.now() + timedelta(days=365)
        cert_end = cert_start + timedelta(days=365)
        cert1 = StubProductCertificate(StubProduct(provided1),
                                       start_date=cert_start,
                                       end_date=cert_end)

        ent_dir = StubCertificateDirectory([cert1])
        pool_filter = PoolFilter(product_dir=StubCertificateDirectory([]),
                                 entitlement_dir=ent_dir)

        begin_date = datetime.now() - timedelta(days=100)
        end_date = datetime.now() + timedelta(days=100)
        pools = [
            create_pool(product1,
                        product1,
                        provided_products=[provided1],
                        start_end_range=DateRange(begin_date, end_date)),
        ]
        result = pool_filter.filter_out_overlapping(pools)
        self.assertEquals(1, len(result))

        result = pool_filter.filter_out_non_overlapping(pools)
        self.assertEquals(0, len(result))
    def test_filter_product_name_matches_provided(self):
        product1 = "Foo Product"
        product2 = "Bar Product"
        pd = StubCertificateDirectory([])
        pool_filter = PoolFilter(product_dir=pd, entitlement_dir=StubCertificateDirectory([]))

        pools = [create_pool(product1, product1, provided_products=[product2])]
        result = pool_filter.filter_product_name(pools, "Bar")
        self.assertEquals(1, len(result))
        self.assertEquals(product1, result[0]["productId"])
    def test_installed_filter_direct_match(self):
        product1 = "product1"
        product2 = "product2"
        pd = StubCertificateDirectory([StubProductCertificate(StubProduct(product2))])
        pool_filter = PoolFilter(product_dir=pd, entitlement_dir=StubCertificateDirectory([]))

        pools = [create_pool(product1, product1), create_pool(product1, product1), create_pool(product2, product2)]
        result = pool_filter.filter_out_installed(pools)
        self.assertEquals(1, len(result))
        self.assertEquals(product1, result[0]["productId"])
Beispiel #6
0
    def test_filter_product_name_matches_provided(self):
        product1 = 'Foo Product'
        product2 = 'Bar Product'
        pd = StubCertificateDirectory([])
        pool_filter = PoolFilter(product_dir=pd,
                                 entitlement_dir=StubCertificateDirectory([]))

        pools = [
            create_pool(product1, product1, provided_products=[product2]),
        ]
        result = pool_filter.filter_product_name(pools, "Bar")
        self.assertEquals(1, len(result))
        self.assertEquals(product1, result[0]['productId'])
    def test_filter_product_name(self):
        product1 = 'Foo Product'
        product2 = 'Bar Product'
        pd = StubCertificateDirectory([])
        pool_filter = PoolFilter(product_dir=pd,
                entitlement_dir=StubCertificateDirectory([]))

        pools = [
                create_pool(product1, product1),
                create_pool(product2, product2),
        ]
        result = pool_filter.filter_product_name(pools, "Foo")
        self.assertEquals(1, len(result))
        self.assertEquals(product1, result[0]['productId'])
    def test_installed_filter_provided_match(self):
        product1 = 'product1'
        product2 = 'product2'
        provided = 'providedProduct'
        pd = StubCertificateDirectory([
            StubProductCertificate(StubProduct(provided))])
        pool_filter = PoolFilter(product_dir=pd,
                entitlement_dir=StubCertificateDirectory([]))

        pools = [
                create_pool(product1, product1),
                create_pool(product2, product2, provided_products=[provided]),
        ]
        result = pool_filter.filter_out_installed(pools)
        self.assertEquals(1, len(result))
        self.assertEquals(product1, result[0]['productId'])
Beispiel #9
0
    def test_installed_filter_provided_match(self):
        product1 = 'product1'
        product2 = 'product2'
        provided = 'providedProduct'
        pd = StubCertificateDirectory(
            [StubProductCertificate(StubProduct(provided))])
        pool_filter = PoolFilter(product_dir=pd,
                                 entitlement_dir=StubCertificateDirectory([]))

        pools = [
            create_pool(product1, product1),
            create_pool(product2, product2, provided_products=[provided]),
        ]
        result = pool_filter.filter_out_installed(pools)
        self.assertEquals(1, len(result))
        self.assertEquals(product1, result[0]['productId'])
    def test_filter_no_overlap(self):
        product1 = "Test Product 1"
        provided1 = "Provided By Test Product 1"

        pd = StubCertificateDirectory([])
        pool_filter = PoolFilter(product_dir=pd,
                entitlement_dir=StubCertificateDirectory([]))

        begin_date = datetime.now() - timedelta(days=10)
        end_date = datetime.now() + timedelta(days=365)
        pools = [
                create_pool(product1, product1, provided_products=[provided1],
                            start_end_range=DateRange(begin_date, end_date)),
        ]
        result = pool_filter.filter_out_overlapping(pools)
        self.assertEquals(1, len(result))

        result = pool_filter.filter_out_non_overlapping(pools)
        self.assertEquals(0, len(result))
Beispiel #11
0
    def test_filter_no_overlap(self):
        product1 = "Test Product 1"
        provided1 = "Provided By Test Product 1"

        pd = StubCertificateDirectory([])
        pool_filter = PoolFilter(product_dir=pd,
                                 entitlement_dir=StubCertificateDirectory([]))

        begin_date = datetime.now() - timedelta(days=10)
        end_date = datetime.now() + timedelta(days=365)
        pools = [
            create_pool(product1,
                        product1,
                        provided_products=[provided1],
                        start_end_range=DateRange(begin_date, end_date)),
        ]
        result = pool_filter.filter_out_overlapping(pools)
        self.assertEquals(1, len(result))

        result = pool_filter.filter_out_non_overlapping(pools)
        self.assertEquals(0, len(result))