diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-02 16:47:10 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-02 17:02:50 -0700 |
commit | 4bb25cec68f1b2613a906e416d4ee3abf9050f6d (patch) | |
tree | 59fdf081fdf841ef08f9188880399e5265f26e5c | |
parent | 675ecb96fe0e51f169c2d01683f02205ef327825 (diff) | |
download | fatcat-4bb25cec68f1b2613a906e416d4ee3abf9050f6d.tar.gz fatcat-4bb25cec68f1b2613a906e416d4ee3abf9050f6d.zip |
hacks to work around new pylint false positives
-rw-r--r-- | python/fatcat_tools/workers/elasticsearch.py | 5 | ||||
-rw-r--r-- | python/tests/transform_elasticsearch.py | 24 |
2 files changed, 18 insertions, 11 deletions
diff --git a/python/fatcat_tools/workers/elasticsearch.py b/python/fatcat_tools/workers/elasticsearch.py index 91f2796c..f411073d 100644 --- a/python/fatcat_tools/workers/elasticsearch.py +++ b/python/fatcat_tools/workers/elasticsearch.py @@ -113,13 +113,14 @@ class ElasticsearchReleaseWorker(FatcatWorker): for msg in batch: json_str = msg.value().decode('utf-8') entity = entity_from_json(json_str, self.entity_type, api_client=ac) + assert isinstance(entity, self.entity_type) if self.entity_type == ChangelogEntry: key = entity.index # might need to fetch from API - if not (entity.editgroup and entity.editgroup.editor): + if not (entity.editgroup and entity.editgroup.editor): # pylint: disable=no-member # (TODO) entity = api.get_changelog_entry(entity.index) else: - key = entity.ident + key = entity.ident # pylint: disable=no-member # (TODO) if self.entity_type != ChangelogEntry and entity.state == 'wip': print(f"WARNING: skipping state=wip entity: {self.entity_type.__name__} {entity.ident}", file=sys.stderr) diff --git a/python/tests/transform_elasticsearch.py b/python/tests/transform_elasticsearch.py index b9011892..c11c5972 100644 --- a/python/tests/transform_elasticsearch.py +++ b/python/tests/transform_elasticsearch.py @@ -204,15 +204,21 @@ def test_elasticsearch_container_transform(journal_metadata_importer): def test_elasticsearch_file_transform(): - f = entity_from_json(open('./tests/files/file_bcah4zp5tvdhjl5bqci2c2lgfa.json', 'r').read(), FileEntity) - - f.state = 'active' - es = file_to_elasticsearch(f) - assert es['sha1'] == f.sha1 - assert es['sha256'] == f.sha256 - assert es['md5'] == f.md5 - assert es['size_bytes'] == f.size - assert es['mimetype'] == f.mimetype + + with open('./tests/files/file_bcah4zp5tvdhjl5bqci2c2lgfa.json', 'r') as f: + json_str = f.read() + + fe = entity_from_json(json_str, FileEntity) + + fe.state = 'active' + es = file_to_elasticsearch(fe) + + # pylint infers type of 'fe' incorrectly for some reason (as str/bytes) + assert es['sha1'] == fe.sha1 # pylint: disable=no-member + assert es['sha256'] == fe.sha256 # pylint: disable=no-member + assert es['md5'] == fe.md5 # pylint: disable=no-member + assert es['size_bytes'] == fe.size # pylint: disable=no-member + assert es['mimetype'] == fe.mimetype # pylint: disable=no-member assert es['in_ia'] == True assert 'web' in es['rels'] |