Ejemplo n.º 1
0
 def test_get_product_info_not_found(self, mock_products_model):
     mock_products_model.query.filter_by.return_value.all.return_value = []
     label = 'Fake-label'
     with pytest.raises(ProductListingsNotFoundError) as excinfo:
         Products.get_product_info(label)
     assert 'Could not find a product with label: {}'.format(label) == str(
         excinfo.value)
Ejemplo n.º 2
0
 def test_get_match_versions(self, mock_matchversions_model):
     product = 'fake-product'
     mock_matchversions_model.query.filter_by.return_value.all.return_value = [
         MatchVersionsModel(name='fake1'),
         MatchVersionsModel(name='fake2'),
     ]
     assert Products.get_match_versions(product) == ['fake1', 'fake2']
 def test_get_match_versions(self, mock_matchversions_model):
     product = "fake-product"
     mock_matchversions_model.query.filter_by.return_value.all.return_value = [
         MatchVersionsModel(name="fake1"),
         MatchVersionsModel(name="fake2"),
     ]
     assert Products.get_match_versions(product) == ["fake1", "fake2"]
Ejemplo n.º 4
0
 def test_get_overrides(self, mock_overrides_model):
     label = 'RHEL-7'
     version = '7.5'
     mock_overrides_model.query.join.return_value.filter.return_value.all.return_value = [
         OverridesModel(name='fake',
                        pkg_arch='src',
                        product_arch='x86_64',
                        include=True),
         OverridesModel(name='fake',
                        pkg_arch='src',
                        product_arch='ppc64',
                        include=True),
         OverridesModel(name='fake',
                        pkg_arch='x86_64',
                        product_arch='x86_64',
                        include=False)
     ]
     assert Products.get_overrides(label, version) == {
         'fake': {
             'src': {
                 'ppc64': True,
                 'x86_64': True
             },
             'x86_64': {
                 'x86_64': False
             }
         }
     }
 def test_get_overrides(self, mock_overrides_model):
     label = "RHEL-7"
     version = "7.5"
     mock_overrides_model.query.join.return_value.filter.return_value.all.return_value = [
         OverridesModel(name="fake",
                        pkg_arch="src",
                        product_arch="x86_64",
                        include=True),
         OverridesModel(name="fake",
                        pkg_arch="src",
                        product_arch="ppc64",
                        include=True),
         OverridesModel(name="fake",
                        pkg_arch="x86_64",
                        product_arch="x86_64",
                        include=False),
     ]
     assert Products.get_overrides(label, version) == {
         "fake": {
             "src": {
                 "ppc64": True,
                 "x86_64": True
             },
             "x86_64": {
                 "x86_64": False
             },
         }
     }
 def test_score(self):
     assert 0 == Products.score("Test1")
     assert 1 == Products.score("alpha")
     assert 2 == Products.score("BETA3")
     assert 3 == Products.score("rc")
     assert 4 == Products.score("Gold")
     assert 5 == Products.score("U5")
     assert 5 == Products.score("U1-beta")
     assert -1 == Products.score("other")
Ejemplo n.º 7
0
 def test_score(self):
     assert 0 == Products.score('Test1')
     assert 1 == Products.score('alpha')
     assert 2 == Products.score('BETA3')
     assert 3 == Products.score('rc')
     assert 4 == Products.score('Gold')
     assert 5 == Products.score('U5')
     assert 5 == Products.score('U1-beta')
     assert -1 == Products.score('other')
    def test_my_sort(self):
        # x starts with y
        assert -1 == Products.my_sort("U1-beta", "U1")

        # y starts with x
        assert 1 == Products.my_sort("U1", "U1-beta")

        # score(x) == score(y)
        assert -1 == Products.my_sort("7.1", "7.2")
        assert -1 == Products.my_sort("U3", "U4")
        assert 1 == Products.my_sort("7.2", "7.1")
        assert 1 == Products.my_sort("U4", "U3")
        assert 0 == Products.my_sort("8.0.0", "8.0.0")

        # score(x) != score(y)
        assert -1 == Products.my_sort("Beta1", "Gold")
        assert 1 == Products.my_sort("6.9", "6.3")
        assert 1 == Products.my_sort("8.1", "8.0.0")
Ejemplo n.º 9
0
    def test_my_sort(self):
        # x starts with y
        assert -1 == Products.my_sort('U1-beta', 'U1')

        # y starts with x
        assert 1 == Products.my_sort('U1', 'U1-beta')

        # score(x) == score(y)
        assert -1 == Products.my_sort('7.1', '7.2')
        assert -1 == Products.my_sort('U3', 'U4')
        assert 1 == Products.my_sort('7.2', '7.1')
        assert 1 == Products.my_sort('U4', 'U3')
        assert 0 == Products.my_sort('8.0.0', '8.0.0')

        # score(x) != score(y)
        assert -1 == Products.my_sort('Beta1', 'Gold')
        assert 1 == Products.my_sort('6.9', '6.3')
        assert 1 == Products.my_sort('8.1', '8.0.0')
Ejemplo n.º 10
0
 def test_precalc_treelist(self, mock_trees_model):
     mock_trees_model.query.join.return_value.order_by.return_value.filter.return_value.filter.return_value.all.return_value = [
         TreesModel(id=3, arch="x86_64"),
         TreesModel(id=2, arch="x86_64"),
         TreesModel(id=1, arch="ppc64"),
     ]
     assert sorted(
         Products.precalc_treelist("fake-product", "7.5",
                                   "Server")) == sorted([1, 3])
Ejemplo n.º 11
0
 def test_precalc_treelist(self, mock_trees_model):
     mock_trees_model.query.join.return_value.order_by.return_value.filter.return_value.filter.return_value.all.return_value = [
         TreesModel(id=3, arch='x86_64'),
         TreesModel(id=2, arch='x86_64'),
         TreesModel(id=1, arch='ppc64'),
     ]
     assert sorted(
         Products.precalc_treelist('fake-product', '7.5',
                                   'Server')) == sorted([1, 3])
Ejemplo n.º 12
0
 def test_get_product_info(self, mock_products_model):
     label = "RHEL-7"
     mock_products_model.query.filter_by.return_value.all.return_value = [
         ProductsModel(id=1, label=label, version="7.2", variant="Server"),
         ProductsModel(id=2, label=label, version="7.3", variant="Server"),
         ProductsModel(id=3, label=label, version="7.4", variant="Server"),
         ProductsModel(id=4, label=label, version="7.4", variant="Client"),
     ]
     result = Products.get_product_info(label)
     assert result == ("7.4", ["Server", "Client"])
Ejemplo n.º 13
0
 def test_get_product_info(self, mock_products_model):
     label = 'RHEL-7'
     mock_products_model.query.filter_by.return_value.all.return_value = [
         ProductsModel(id=1, label=label, version='7.2', variant='Server'),
         ProductsModel(id=2, label=label, version='7.3', variant='Server'),
         ProductsModel(id=3, label=label, version='7.4', variant='Server'),
         ProductsModel(id=4, label=label, version='7.4', variant='Client')
     ]
     result = Products.get_product_info(label)
     assert result == ('7.4', ['Server', 'Client'])
Ejemplo n.º 14
0
 def test_get_product_labels(self, mock_products_model):
     mock_products_model.query.with_entities.return_value.distinct.return_value.all.return_value = [
         ProductsModel(label='label1'),
         ProductsModel(label='label2'),
     ]
     assert Products.get_product_labels() == [{
         'label': 'label1'
     }, {
         'label': 'label2'
     }]
Ejemplo n.º 15
0
 def test_get_product_labels(self, mock_products_model):
     mock_products_model.query.with_entities.return_value.distinct.return_value.all.return_value = [
         ProductsModel(label="label1"),
         ProductsModel(label="label2"),
     ]
     assert Products.get_product_labels() == [
         {
             "label": "label1"
         },
         {
             "label": "label2"
         },
     ]
Ejemplo n.º 16
0
 def test_get_module_overrides(self, mock_moduleoverrides_model):
     module_name = 'perl'
     module_stream = '5.24'
     mock_moduleoverrides_model.query.join.return_value.filter.return_value.filter.return_value.all.return_value = [
         ModuleOverridesModel(name=module_name,
                              stream=module_stream,
                              product=1,
                              product_arch='x86_64'),
         ModuleOverridesModel(name=module_name,
                              stream=module_stream,
                              product=1,
                              product_arch='ppc64le'),
         ModuleOverridesModel(name=module_name,
                              stream=module_stream,
                              product=1,
                              product_arch='s390x'),
     ]
     assert Products.get_module_overrides(
         'fake', 'fake', module_name, module_stream,
         'fake') == ['x86_64', 'ppc64le', 's390x']
Ejemplo n.º 17
0
 def test_get_module_overrides(self, mock_moduleoverrides_model):
     module_name = "perl"
     module_stream = "5.24"
     mock_moduleoverrides_model.query.join.return_value.filter.return_value.filter.return_value.all.return_value = [
         ModuleOverridesModel(name=module_name,
                              stream=module_stream,
                              product=1,
                              product_arch="x86_64"),
         ModuleOverridesModel(
             name=module_name,
             stream=module_stream,
             product=1,
             product_arch="ppc64le",
         ),
         ModuleOverridesModel(name=module_name,
                              stream=module_stream,
                              product=1,
                              product_arch="s390x"),
     ]
     assert Products.get_module_overrides(
         "fake", "fake", module_name, module_stream,
         "fake") == ["x86_64", "ppc64le", "s390x"]
Ejemplo n.º 18
0
def dbh():
    return Products.compose_get_dbh()
Ejemplo n.º 19
0
 def test_get_product_info(self, dbh):
     product = 'RHEL-6-Server-EXTRAS-6'
     result = Products.get_product_info(dbh, product)
     assert result == ('6.9', ['EXTRAS-6'])
Ejemplo n.º 20
0
 def test_get_product_info(self, app):
     product = "RHEL-6-Server-EXTRAS-6"
     result = Products.get_product_info(product)
     assert result == ("6.9", ["EXTRAS-6"])