Пример #1
0
def test_get_classifier_ids(dbapp):
    dbapp.engine.execute(classifiers.insert().values(
        id=1,
        classifier="Test :: Classifier",
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=2,
        classifier="Test :: Another",
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=3,
        classifier="Test :: The Other One",
    ))

    test_classifiers = dbapp.models.packaging.get_classifier_ids(
        ["Test :: Classifier", "Test :: The Other One"])

    assert test_classifiers == {
        "Test :: Classifier": 1,
        "Test :: The Other One": 3
    }
Пример #2
0
def test_get_classifier_ids(dbapp):
    dbapp.engine.execute(classifiers.insert().values(
        id=1,
        classifier="Test :: Classifier",
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=2,
        classifier="Test :: Another",
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=3,
        classifier="Test :: The Other One",
    ))

    test_classifiers = dbapp.db.packaging.get_classifier_ids(
        ["Test :: Classifier", "Test :: The Other One"]
    )

    assert test_classifiers == {
        "Test :: Classifier": 1,
        "Test :: The Other One": 3
    }
Пример #3
0
def test_search_by_classifier(search, result, dbapp):
    dbapp.engine.execute(classifiers.insert().values(
        id=1,
        classifier="Test :: Classifier",
        l2=1,
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=2, classifier="Test :: Classifier :: More", l2=1, l3=2))
    dbapp.engine.execute(classifiers.insert().values(
        id=5, classifier="Test :: Classifier :: Alternative", l2=1, l3=5))
    dbapp.engine.execute(classifiers.insert().values(
        id=3, classifier="Test :: Classifier :: More :: Wow", l2=1, l3=2,
        l4=3))
    dbapp.engine.execute(classifiers.insert().values(
        id=4,
        classifier="Test :: Classifier :: More :: Wow :: So Classifier",
        l2=1,
        l3=2,
        l4=3,
        l5=4))
    dbapp.engine.execute(classifiers.insert().values(
        id=6, classifier="Other :: Thing", l2=6))
    dbapp.engine.execute(classifiers.insert().values(
        id=7, classifier="Other :: Thing :: Moar", l2=6, l3=7))

    def add_project(name, classifiers):
        dbapp.engine.execute(packages.insert().values(name=name))
        dbapp.engine.execute(releases.insert().values(name=name, version="1"))
        for trove_id in classifiers:
            dbapp.engine.execute(release_classifiers.insert().values(
                name=name,
                version="1",
                trove_id=trove_id,
            ))

    add_project('one', [1])
    add_project('two', [2])
    add_project('four-six', [4, 6])
    add_project('seven', [7])

    response = dbapp.models.packaging.search_by_classifier(search)
    assert sorted(response) == sorted(result)
Пример #4
0
def test_get_classifiers(dbapp):
    dbapp.engine.execute(packages.insert().values(name="test-project"))
    dbapp.engine.execute(releases.insert().values(
        name="test-project",
        version="1.0",
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=1,
        classifier="Test :: Classifier",
    ))
    dbapp.engine.execute(release_classifiers.insert().values(
        name="test-project",
        version="1.0",
        trove_id=1,
    ))

    test_classifiers = dbapp.models.packaging.get_classifiers(
        "test-project",
        "1.0",
    )

    assert test_classifiers == ["Test :: Classifier"]
Пример #5
0
def test_get_classifiers(dbapp):
    dbapp.engine.execute(packages.insert().values(name="test-project"))
    dbapp.engine.execute(releases.insert().values(
        name="test-project",
        version="1.0",
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=1,
        classifier="Test :: Classifier",
    ))
    dbapp.engine.execute(release_classifiers.insert().values(
        name="test-project",
        version="1.0",
        trove_id=1,
    ))

    test_classifiers = dbapp.db.packaging.get_classifiers(
        "test-project",
        "1.0",
    )

    assert test_classifiers == ["Test :: Classifier"]
Пример #6
0
def test_search_by_classifier(search, result, dbapp):
    dbapp.engine.execute(classifiers.insert().values(
        id=1,
        classifier="Test :: Classifier",
        l2=1,
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=2,
        classifier="Test :: Classifier :: More",
        l2=1,
        l3=2
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=5,
        classifier="Test :: Classifier :: Alternative",
        l2=1,
        l3=5
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=3,
        classifier="Test :: Classifier :: More :: Wow",
        l2=1,
        l3=2,
        l4=3
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=4,
        classifier="Test :: Classifier :: More :: Wow :: So Classifier",
        l2=1,
        l3=2,
        l4=3,
        l5=4
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=6,
        classifier="Other :: Thing",
        l2=6
    ))
    dbapp.engine.execute(classifiers.insert().values(
        id=7,
        classifier="Other :: Thing :: Moar",
        l2=6,
        l3=7
    ))

    def add_project(name, classifiers):
        dbapp.engine.execute(packages.insert().values(name=name))
        dbapp.engine.execute(releases.insert().values(name=name, version="1"))
        for trove_id in classifiers:
            dbapp.engine.execute(release_classifiers.insert().values(
                name=name,
                version="1",
                trove_id=trove_id,
            ))

    add_project('one', [1])
    add_project('two', [2])
    add_project('four-six', [4, 6])
    add_project('seven', [7])

    response = dbapp.db.packaging.search_by_classifier(search)
    assert sorted(response) == sorted(result)