Beispiel #1
0
    def test_add_child_classifier(self, db_request, parent_levels,
                                  expected_levels):
        l2, l3, l4, l5 = parent_levels
        parent = ClassifierFactory(l2=l2,
                                   l3=l3,
                                   l4=l4,
                                   l5=l5,
                                   classifier='Parent')

        db_request.params = {
            'parent_id': parent.id,
            'child': 'Foobar',
        }
        db_request.session.flash = pretend.call_recorder(lambda *a, **kw: None)
        db_request.route_path = lambda *a: '/the/path'

        views.AddClassifier(db_request).add_child_classifier()

        new = (db_request.db.query(Classifier).filter(
            Classifier.classifier == 'Parent :: Foobar').one())

        new_l2, new_l3, new_l4, new_l5 = expected_levels
        assert new.l2 == new_l2 if new_l2 is not None else new.id
        assert new.l3 == new_l3 if new_l3 is not None else new.id
        assert new.l4 == new_l4 if new_l4 is not None else new.id
        assert new.l5 == new_l5 if new_l5 is not None else new.id
Beispiel #2
0
    def test_add_private_parent_classifier(self, db_request,
                                           parent_classifier):
        db_request.params = {"parent": f"{parent_classifier} :: Do Not Upload"}
        db_request.session.flash = pretend.call_recorder(lambda *a, **kw: None)
        db_request.route_path = lambda *a: "/the/path"

        with pytest.raises(sqlalchemy.exc.IntegrityError):
            views.AddClassifier(db_request).add_parent_classifier()
Beispiel #3
0
    def test_add_parent_classifier(self, db_request):
        db_request.params = {'parent': 'Foo :: Bar'}
        db_request.session.flash = pretend.call_recorder(lambda *a, **kw: None)
        db_request.route_path = lambda *a: '/the/path'

        views.AddClassifier(db_request).add_parent_classifier()

        new = (db_request.db.query(Classifier).filter(
            Classifier.classifier == 'Foo :: Bar').one())

        assert new.l2 == new.id
        assert new.l3 == 0
        assert new.l4 == 0
        assert new.l5 == 0
Beispiel #4
0
    def test_add_private_child_classifier(self, db_request, parent_classifier,
                                          parent_levels, expected_levels):
        l2, l3, l4, l5 = parent_levels
        parent = ClassifierFactory(l2=l2,
                                   l3=l3,
                                   l4=l4,
                                   l5=l5,
                                   classifier=parent_classifier)

        db_request.params = {"parent_id": parent.id, "child": "Foobar"}
        db_request.session.flash = pretend.call_recorder(lambda *a, **kw: None)
        db_request.route_path = lambda *a: "/the/path"

        with pytest.raises(sqlalchemy.exc.IntegrityError):
            views.AddClassifier(db_request).add_child_classifier()