Example #1
0
    def test_get_document_fetches_a_document_with_the_proper_id_supplied_as_uuid(self):
        doc_id = uuid.uuid4()
        tu.save_document({'_id': doc_id, 'type': 'zagnut'})
        the_dict = tu.get_document(doc_id)

        assert the_dict
        assert the_dict['_id'] == str(doc_id)
Example #2
0
    def test_get_document_fetches_a_document_with_the_proper_id_supplied_as_uuid(
            self):
        doc_id = uuid.uuid4()
        tu.save_document({'_id': doc_id, 'type': 'zagnut'})
        the_dict = tu.get_document(doc_id)

        assert the_dict
        assert the_dict['_id'] == str(doc_id)
Example #3
0
    def test_generic_save_view_gets_args_from_create_distortion_pair_request_data(self):
        with current_app.test_client() as c:
            resp_object = c.post('/api/v1/calibration/distortion_pairs',
                                 headers={'Content-Type':'application/json'},
                                 data='{"thermo":"plastic"}')
            assert resp_object.status_code == 200

            doc_id = json.loads(resp_object.data)['_id']
            distortion_pair_document = get_document(doc_id)
            assert 'thermo' in distortion_pair_document
Example #4
0
    def test_generic_save_view_gets_args_from_create_distortion_pair_request_data(
            self):
        with current_app.test_client() as c:
            resp_object = c.post('/api/v1/calibration/distortion_pairs',
                                 headers={'Content-Type': 'application/json'},
                                 data='{"thermo":"plastic"}')
            assert resp_object.status_code == 200

            doc_id = json.loads(resp_object.data)['_id']
            distortion_pair_document = get_document(doc_id)
            assert 'thermo' in distortion_pair_document
Example #5
0
    def test_clean_up_files_cleans_pictures_from_the_snap_and_updates_snap_document(self):
        snap_id = uuid.uuid4()
        group_id = adms.get_group_document('current')['_id']
        pic_ids = self.build_three_pictures(snap_id)
        for pic_id in pic_ids:
            pic_doc = get_document(pic_id)
            assert os.path.isfile(pic_doc['uri'])
            assert str(snap_id) in pic_doc['uri']

        assert os.path.isdir(os.path.join(current_app.config['PICTURE_SAVE_DIRECTORY'], str(snap_id)))
        with current_app.test_request_context('/whatever'):  # needs a context because clean_up_files calls search_generic
            adms.clean_up_files(snap_id, group_id)

        for pic_id in pic_ids:
            pic_doc = get_document(pic_id)
            filename = build_picture_name(pic_id)
            expected_picture_path = os.path.join(current_app.config['PICTURE_SAVE_DIRECTORY'], filename)
            assert pic_doc['uri'] == expected_picture_path
            assert os.path.isfile(expected_picture_path)
        assert not os.path.isdir(os.path.join(current_app.config['PICTURE_SAVE_DIRECTORY'], str(snap_id)))
        snap_document = get_document(snap_id)
        assert snap_document['files_have_been_cleaned_up'] == True
Example #6
0
def get_generic(item_id, document_type):
    if not item_exists(item_id, document_type):
        raise NotFoundError("{0} not found for id {1}".format(document_type, item_id))
    item_dict = get_document(item_id)
    return item_dict
Example #7
0
    def test_get_document_returns_none_when_document_not_found(self):
        doc_id = uuid.uuid4()
        the_dict = tu.get_document(doc_id)

        assert not the_dict
Example #8
0
    def test_get_document_returns_none_when_document_not_found(self):
        doc_id = uuid.uuid4()
        the_dict = tu.get_document(doc_id)

        assert not the_dict