Beispiel #1
0
def test_public_fields():
    
    class PublicFieldsModule(object):
        pass

    entity = PublicFieldsModule()
    entity.FIELDS = [
        {"elasticsearch": {"public": True}, "name": "id"},
        {"elasticsearch": {"public": True}, "name": "title"},
        {"elasticsearch": {"public": False}, "name": "notes"},
        {"name": "noelastic"}
    ]
    file_ = PublicFieldsModule()
    file_.FIELDS = [
        {"elasticsearch": {"public": True}, "name": "id"},
        {"elasticsearch": {"public": True}, "name": "title"},
        {"elasticsearch": {"public": False}, "name": "notes"},
        {"name": "noelastic"}
    ]
    MODULES = {
        'entity': entity,
        'file': file_,
    }
    EXPECTED = {
        'entity': ['id', 'title'],
        'file': ['id', 'title', 'path_rel', 'id'],
    }
    assert docstore._public_fields(MODULES) == EXPECTED
Beispiel #2
0
 def post_json(self):
     # NOTE: this is same basic code as Docstore.index
     return docstore.Docstore().post(
         self,
         docstore._public_fields().get(self.identifier.model, []), {
             'parent_id': self.identifier.parent_id(),
         })
Beispiel #3
0
 def post_json(self):
     # NOTE: this is same basic code as docstore.index
     return docstore.DocstoreManager(
         docstore.INDEX_PREFIX, config.DOCSTORE_HOST, config).post(
             self,
             docstore._public_fields().get(self.identifier.model, []), {
                 'parent_id': self.parent_id,
             })
Beispiel #4
0
 def post_json(self):
     # NOTE: this is same basic code as docstore.index
     return docstore.Docstore().post(
         self,
         docstore._public_fields().get(self.identifier.model, []),
         {
             'parent_id': self.parent_id,
         }
     )
Beispiel #5
0
def test_public_fields():
    class PublicFieldsModule(object):
        pass

    entity = PublicFieldsModule()
    entity.FIELDS = [{
        "elasticsearch": {
            "public": True
        },
        "name": "id"
    }, {
        "elasticsearch": {
            "public": True
        },
        "name": "title"
    }, {
        "elasticsearch": {
            "public": False
        },
        "name": "notes"
    }, {
        "name": "noelastic"
    }]
    file_ = PublicFieldsModule()
    file_.FIELDS = [{
        "elasticsearch": {
            "public": True
        },
        "name": "id"
    }, {
        "elasticsearch": {
            "public": True
        },
        "name": "title"
    }, {
        "elasticsearch": {
            "public": False
        },
        "name": "notes"
    }, {
        "name": "noelastic"
    }]
    MODULES = {
        'entity': entity,
        'file': file_,
    }
    EXPECTED = {
        'entity': ['id', 'title'],
        'file': ['id', 'title', 'path_rel', 'id'],
    }
    assert docstore._public_fields(MODULES) == EXPECTED