Skip to content

Commit

Permalink
flake8 + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
masipcat committed Feb 27, 2020
1 parent 469cce0 commit 49761b3
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 31 deletions.
3 changes: 2 additions & 1 deletion guillotina_elasticsearch/commands/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ async def check_missing(self):
indexes = self.get_indexes_for_oids(oids)
try:
results = await self.conn.search(
','.join(indexes), body={
index=','.join(indexes),
body={
'query': {
'terms': {
'uuid': oids
Expand Down
2 changes: 1 addition & 1 deletion guillotina_elasticsearch/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IIndexProgress(Interface):
@implementer(IIndexProgress)
class IndexProgress(object):

def __init__(self, context, processed, total, completed=None, request=None):
def __init__(self, context, processed, total, completed=None, request=None): # noqa
self.request = request
self.context = context
self.processed = processed
Expand Down
2 changes: 0 additions & 2 deletions guillotina_elasticsearch/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from guillotina.interfaces import IResource
from guillotina.transactions import get_transaction
from guillotina.utils import execute
from guillotina.utils import find_container
from guillotina.utils import get_registry as guillotina_get_registry
from guillotina.utils import resolve_dotted_name
from guillotina_elasticsearch.directives import index
Expand All @@ -26,7 +25,6 @@
from guillotina_elasticsearch.interfaces import SUB_INDEX_SEPERATOR
from guillotina_elasticsearch.schema import get_mappings
from guillotina_elasticsearch.utils import get_migration_lock
from typing import Dict, Any
from zope.interface import alsoProvides
from zope.interface.interface import TAGGED_DATA

Expand Down
10 changes: 0 additions & 10 deletions guillotina_elasticsearch/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from guillotina.interfaces import ISearchParser
from guillotina_elasticsearch.interfaces import IElasticSearchUtility
from guillotina_elasticsearch.interfaces import ParsedQueryInfo
from guillotina.utils import get_content_depth
from guillotina.utils import get_content_path
import logging
import typing

Expand Down Expand Up @@ -211,11 +209,3 @@ def __call__(self, params: typing.Dict) -> ParsedQueryInfo:
query_info,
query=query
))

def get_context_params(self) -> (str, int,):
depth = int(self.request.query.get("depth", 5))
path = get_content_path(self.context)
return (
get_content_path(self.context),
get_content_depth(self.context) + depth
)
1 change: 0 additions & 1 deletion guillotina_elasticsearch/reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from guillotina_elasticsearch.interfaces import IIndexManager
from guillotina_elasticsearch.migration import Migrator
from guillotina_elasticsearch.utils import find_index_manager
from guillotina.utils import get_current_container


class Reindexer(Migrator):
Expand Down
2 changes: 0 additions & 2 deletions guillotina_elasticsearch/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,3 @@ def get_mappings(schemas=None, schema_info=False):
return {
'properties': mappings
}

return result
1 change: 0 additions & 1 deletion guillotina_elasticsearch/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from guillotina.content import Folder
from guillotina.exceptions import RequestNotFound
from guillotina.interfaces import IResource
from guillotina.utils import get_current_request
from guillotina_elasticsearch.directives import index
from guillotina_elasticsearch.interfaces import IConnectionFactoryUtility
from guillotina_elasticsearch.interfaces import IContentIndex
Expand Down
2 changes: 0 additions & 2 deletions guillotina_elasticsearch/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

import pytest


pytestmark = [pytest.mark.asyncio]



async def test_index(es_requester):
async with es_requester as requester:
container, request, txn, tm = await setup_txn_on_container(requester) # noqa
Expand Down
6 changes: 3 additions & 3 deletions guillotina_elasticsearch/tests/test_custom_index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from guillotina.component import get_utility
from guillotina.db.uid import get_short_uid
from guillotina.interfaces import ICatalogUtility
from guillotina.transactions import transaction
from guillotina_elasticsearch.tests.utils import run_with_retries
from guillotina_elasticsearch.tests.utils import setup_txn_on_container
from guillotina_elasticsearch.utils import get_content_sub_indexes
Expand Down Expand Up @@ -197,8 +196,9 @@ async def test_delete_base_removes_index_from_elastic(es_requester):

async def _test():
# should find in content index but not main index
await catalog.get_connection().get(
index=content_index_name, doc_type='_all', id=resp['@uid'])
with pytest.raises(aioelasticsearch.exceptions.NotFoundError):
await catalog.get_connection().get(
index=content_index_name, doc_type='_all', id=resp['@uid'])
with pytest.raises(aioelasticsearch.exceptions.NotFoundError):
await catalog.get_connection().get(
index='guillotina-guillotina',
Expand Down
2 changes: 1 addition & 1 deletion guillotina_elasticsearch/tests/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def _test():
await run_with_retries(_test, requester)


@pytest.mark.flaky(reruns=5)
# @pytest.mark.flaky(reruns=5)
async def test_fixes_missing(es_requester):
async with es_requester as requester:
await add_content(requester, 2, 2)
Expand Down
2 changes: 2 additions & 0 deletions guillotina_elasticsearch/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import pytest

pytestmark = [pytest.mark.asyncio]


class IA(Interface):
index_field('item', field_mapping={'type': 'integer'})
Expand Down
2 changes: 1 addition & 1 deletion guillotina_elasticsearch/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def setup_txn_on_container(requester, container_id='guillotina'):
utils.login()
request = utils.get_mocked_request(db=requester.db)
task_vars.request.set(request)
container = await get_container(requester=requester, container_id=container_id)
container = await get_container(requester=requester, container_id=container_id) # noqa
tm = task_vars.tm.get()
txn = await tm.begin()
return container, request, txn, tm
Expand Down
5 changes: 0 additions & 5 deletions guillotina_elasticsearch/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
from guillotina import app_settings
from guillotina import configure
from guillotina.catalog.catalog import DefaultSearchUtility
from guillotina.catalog import index
from guillotina.catalog.utils import parse_query
from guillotina.component import get_adapter
from guillotina.component import get_utility
from guillotina.event import notify
from guillotina.exceptions import RequestNotFound
from guillotina_elasticsearch.exceptions import ElasticsearchConflictException
from guillotina.interfaces import IAbsoluteURL
from guillotina.interfaces import IFolder
from guillotina.transactions import get_transaction
from guillotina.utils import get_content_depth
Expand All @@ -28,13 +25,11 @@
from guillotina_elasticsearch.interfaces import IElasticSearchUtility # noqa b/w compat import
from guillotina_elasticsearch.interfaces import IIndexActive
from guillotina_elasticsearch.interfaces import IIndexManager
from guillotina_elasticsearch.interfaces import ParsedQueryInfo
from guillotina_elasticsearch.utils import find_index_manager
from guillotina_elasticsearch.utils import format_hit
from guillotina_elasticsearch.utils import get_content_sub_indexes
from guillotina_elasticsearch.utils import noop_response
from guillotina_elasticsearch.utils import safe_es_call

from os.path import join

import aiohttp
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

test_requires = [
'async_asgi_testclient',
'pytest>=3.6',
'pytest>=5.0',
'docker',
'backoff',
'psycopg2-binary',
Expand Down

0 comments on commit 49761b3

Please sign in to comment.