Skip to content

Commit

Permalink
take some changes from Kent
Browse files Browse the repository at this point in the history
  • Loading branch information
willronchetti committed Jul 21, 2023
1 parent 9df0810 commit b554fcc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/encoded/tests/test_ingestion_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def wait_for_queue_to_catch_up(queue_manager, n, initially=False):
"""
Wait until queue has done the things we told it to do.
Pause for enough time that probably the queue has done the things we told it to do.
Right now this just sleeps for QUEUE_CATCH_UP_WAIT_SECONDS seconds
in any non-initial situation (i.e., where initially is False),
Expand Down Expand Up @@ -76,7 +76,7 @@ class MockedEnv:

@classmethod
def new_name(cls):
cls._last_version = last_version = int(datetime.datetime.now().timestamp() * 1000000)
cls._last_version = last_version = int(datetime.datetime.now().timestamp() * 1000000) # microseconds
return "%s%s" % (cls.MOCKED_ENV_PREFIX, last_version)


Expand Down
35 changes: 18 additions & 17 deletions src/encoded/tests/verifier.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from dcicutils.misc_utils import ignored
from dcicutils.misc_utils import ignored, PRINT
from functools import wraps
from snovault import TYPES
from .test_create_mapping import test_create_mapping_correctly_maps_embeds
#from .test_embedding import test_add_default_embeds, test_manual_embeds
#from .test_schemas import compute_master_mixins, test_load_schema
# from .test_embedding import test_add_default_embeds, test_manual_embeds
# from .test_schemas import compute_master_mixins, test_load_schema


def verifier(func):
@wraps(func)
def wrapper(*args, **kwargs):
print("running tests " + func.__name__)
PRINT(f"running tests {func.__name__}")
try:
res = func(*args, **kwargs)
except Exception as e:
print("test failed with exception " + str(e.args))
PRINT(f"test failed with exception {e}")
else:
print("success")
PRINT("success")
return res
return wrapper

Expand Down Expand Up @@ -51,19 +51,20 @@ def verify_profile(item_type, indexer_testapp):
# is this something we actually know about?
profile = indexer_testapp.get("/profiles/" + item_type + ".json").json
assert profile
# transform profile page path to camel case item type
item_type_camel = profile['id'].strip('.json').split('/')[-1]
return item_type_camel


@verifier
def verify_schema(item_type_camel, registry):
# test schema
test_load_schema(item_type_camel + ".json", compute_master_mixins(), registry)
# @verifier
# def verify_schema(item_type_camel, registry):
# # test schema
# test_load_schema(item_type_camel + ".json", compute_master_mixins(), registry)


@verifier
def verify_can_embed(item_type_camel, es_item, indexer_testapp, registry):
# get the embedds
# get the embeds
pyr_item_type = registry[TYPES].by_item_type[item_type_camel]
embeds = pyr_item_type.embedded

Expand All @@ -79,10 +80,10 @@ def verify_indexing(item_uuid, indexer_testapp):
assert res


@verifier
def verify_embeds(registry, item_type):
test_add_default_embeds(registry, item_type)
test_manual_embeds(registry, item_type)
# @verifier
# def verify_embeds(registry, item_type):
# test_add_default_embeds(registry, item_type)
# test_manual_embeds(registry, item_type)


@verifier
Expand All @@ -96,10 +97,10 @@ def verify_item(item_uuid, indexer_testapp, testapp, registry):
verify_get_by_accession(es_item, item_type, indexer_testapp)
verify_get_from_db(item_uuid, item_type, indexer_testapp)
item_type_camel = verify_profile(item_type, indexer_testapp)
verify_schema(item_type_camel, registry)
# verify_schema(item_type_camel, registry)
verify_can_embed(item_type_camel, es_item, indexer_testapp, registry)
verify_indexing(item_uuid, indexer_testapp)
verify_embeds(registry, item_type_camel)
# verify_embeds(registry, item_type_camel)
verify_mapping(registry, item_type_camel)


Expand Down
4 changes: 2 additions & 2 deletions src/encoded/types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def __init__(self, *args, **kw):
super(Collection, self).__init__(*args, **kw)
if hasattr(self, '__acl__'):
if DEBUG_PERMISSIONS:
PRINT(f'DEBUG_PERMISSIONS: returning {self.__acl__} for {self.type_info.name}')
PRINT(f'DEBUG_PERMISSIONS: using {self.__acl__} for {self.type_info.name}')
return

# If no ACLs are defined for collection, allow submission centers to add/create
if 'submission_centers' in self.type_info.factory.schema['properties']:
if DEBUG_PERMISSIONS:
PRINT(f'DEBUG_PERMISSIONS: returning {ALLOW_SUBMISSION_CENTER_CREATE_ACL} for {self.type_info.name}')
PRINT(f'DEBUG_PERMISSIONS: using {ALLOW_SUBMISSION_CENTER_CREATE_ACL} for {self.type_info.name}')
self.__acl__ = ALLOW_SUBMISSION_CENTER_CREATE_ACL
else:
self.__acl__ = ONLY_ADMIN_VIEW_ACL
Expand Down

0 comments on commit b554fcc

Please sign in to comment.