Beispiel #1
0
def add_document_to_guided_tour(tour_id):
    doc_id = request.form.get('doc_id')
    if doc_id is None or tour_id is None:
        raise BadRequest("Parameter is missing : 'doc_id'")

    guided_tour = TourController.add_document(tour_id, doc_id)
    return ResponseCreated(guided_tour)
Beispiel #2
0
 def test_update_tour_1(self):
     DocController.create_document({
         "title": "title",
         "source": "source1",
         "description": "a description",
         "file": "1.gif",
         'user_id': 1,
         'role': {'label': 'admin'}
     }, {
         'user_id': 1
     })
     DocController.create_document({
         "title": "title2",
         "source": "source2",
         "description": "a description",
         "file": "1.gif",
         'user_id': 1,
         'role': {'label': 'admin'}
     }, {
         'user_id': 1
     })
     print("adding existing document")
     expected_response = {
         'extendedDocs': [{
             'id': 1,
             'title': None,
             'tour_id': 1,
             'doc_position': 1,
             'text2': None,
             'doc_id': 1,
             'document': {
                 'id': 1,
                 'validationStatus': {
                     'status': Status.Validated,
                     'doc_id': 1
                 },
                 'user_id': 1,
                 'comments': [],
                 'title': 'title',
                 'publicationDate': None,
                 'file': '1.gif',
                 'description': 'a description',
                 'source': 'source1',
                 'rightsHolder': None,
                 'refDate': None,
                 'visualization': {
                     'positionZ': None,
                     'id': 1,
                     'quaternionW': None,
                     'positionY': None,
                     'quaternionZ': None,
                     'quaternionX': None,
                     'positionX': None,
                     'quaternionY': None}},
             'text1': None}],
         'name': 'First tour',
         'id': 1,
         'description': 'This is the first guided tour'
     }
     assert expected_response == TourController.add_document(1, 1)
Beispiel #3
0
def add_document_to_guided_tour():
    tour_id = request.args.get("tour_id")
    doc_id = request.args.get('doc_id')
    if doc_id is None or tour_id is None:
        return 'parameter is missing', 400

    return send_response(
        lambda: TourController.add_document(tour_id, doc_id))()
Beispiel #4
0
    def update_tours():
        print("\n\033[01m## Updating ##\033[0m")
        make_test(lambda: TourController.add_document(1, 1))(
            GuidedTourTest, "adding existing document", False)

        make_test(lambda: TourController.add_document(1, 1))(
            GuidedTourTest, "adding twice existing document", False)

        make_test(lambda: TourController.add_document(1, 2))(
            GuidedTourTest, "adding existing document", False)

        make_test(lambda: TourController.add_document(2, 1))(
            GuidedTourTest, "adding existing document", False)

        make_test(lambda: TourController.add_document(1, 3))(
            GuidedTourTest, "adding non existing document", True)

        make_test(lambda: TourController.add_document(-1, 3))(
            GuidedTourTest, "adding non existing document", True)

        make_test(
            lambda: TourController.update(1, {
                'title': 'this is a new title',
                'description': 'new description'
            }))(GuidedTourTest, "updating existing guided tour", False)

        make_test(lambda: TourController.update_document(
            1, 1, {'text1': 'this is a text'}))(
                GuidedTourTest, "updating guided tour document", False)
 def test_update_tour_3(self):
     print("adding non existing document")
     with pytest.raises(sqlalchemy.exc.IntegrityError):
         TourController.add_document(1, 3)
 def test_update_tour_2(self):
     print("adding twice existing document")
     expected_response = {
         'extendedDocs': [{
             'id': 1,
             'title': None,
             'tour_id': 1,
             'doc_position': 1,
             'text2': None,
             'doc_id': 1,
             'document': {
                 'id': 1,
                 'comments': [],
                 'validationStatus': {
                     'status': Status.Validated,
                     'doc_id': 1
                 },
                 'user_id': 1,
                 'title': 'title',
                 'type': 'type',
                 'publicationDate': None,
                 'file': '1.gif',
                 'description': 'a description',
                 'subject': 'Subject1',
                 'originalName': None,
                 'refDate': None,
                 'visualization': {
                     'positionZ': None,
                     'id': 1,
                     'quaternionW': None,
                     'positionY': None,
                     'quaternionZ': None,
                     'quaternionX': None,
                     'positionX': None,
                     'quaternionY': None
                 },
             },
             'text1': None
         }, {
             'id': 2,
             'title': None,
             'tour_id': 1,
             'doc_position': 2,
             'text2': None,
             'doc_id': 1,
             'document': {
                 'id': 1,
                 'comments': [],
                 'validationStatus': {
                     'status': Status.Validated,
                     'doc_id': 1
                 },
                 'user_id': 1,
                 'title': 'title',
                 'type': 'type',
                 'publicationDate': None,
                 'file': '1.gif',
                 'description': 'a description',
                 'subject': 'Subject1',
                 'originalName': None,
                 'refDate': None,
                 'visualization': {
                     'positionZ': None,
                     'id': 1,
                     'quaternionW': None,
                     'positionY': None,
                     'quaternionZ': None,
                     'quaternionX': None,
                     'positionX': None,
                     'quaternionY': None
                 }
             },
             'text1': None
         }],
         'name':
         'First tour',
         'id':
         1,
         'description':
         'This is the first guided tour'
     }
     assert expected_response == TourController.add_document(1, 1)