Example #1
0
    def test_change_status(self):
        data = MetaDataDB.query.join(Publisher). \
            filter(Publisher.name == self.publisher_one,
                   MetaDataDB.name == self.package_one).one()
        self.assertEqual('active', data.status)

        MetaDataDB.change_status(self.publisher_one, self.package_one)

        data = MetaDataDB.query.join(Publisher). \
            filter(Publisher.name == self.publisher_one,
                   MetaDataDB.name == self.package_one).one()
        self.assertEqual('deleted', data.status)

        MetaDataDB.change_status(self.publisher_one,
                                 self.package_one,
                                 status='active')

        data = MetaDataDB.query.join(Publisher). \
            filter(Publisher.name == self.publisher_one,
                   MetaDataDB.name == self.package_one).one()
        self.assertEqual('active', data.status)
Example #2
0
def delete_data_package(publisher, package):
    """
    DPR data package soft delete operation operation.
    This API is responsible for mark for delete of data package
    ---
    tags:
        - package
    parameters:
        - in: path
          name: publisher
          type: string
          required: true
          description: publisher name
        - in: path
          name: package
          type: string
          required: true
          description: package name
    responses:
        500:
            description: Internal Server Error
        200:
            description: Success Message
            schema:
                id: put_package_success
                properties:
                    status:
                        type: string
                        default: OK
    """
    try:
        bitstore = BitStore(publisher=publisher, package=package)
        status_acl = bitstore.change_acl('private')
        status_db = MetaDataDB.change_status(publisher, package)
        if status_acl and status_db:
            return jsonify({"status": "OK"}), 200
        if not status_acl:
            raise Exception('Failed to change acl')
        if not status_db:
            raise Exception('Failed to change status')
    except Exception as e:
        app.logger.error(e)
        return handle_error('GENERIC_ERROR', e.message, 500)
Example #3
0
 def test_return_false_if_failed_to_change_status(self):
     status = MetaDataDB.change_status(self.publisher_one,
                                       'fake_package',
                                       status='active')
     self.assertFalse(status)