Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ted 51 #22

Merged
merged 24 commits into from
Mar 15, 2022
Merged

Feature/ted 51 #22

merged 24 commits into from
Mar 15, 2022

Conversation

kaleanych
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Mar 10, 2022

Codecov Report

Merging #22 (7b10290) into main (58608bb) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
- Coverage   96.37%   96.32%   -0.05%     
==========================================
  Files          26       33       +7     
  Lines         744      979     +235     
==========================================
+ Hits          717      943     +226     
- Misses         27       36       +9     
Impacted Files Coverage Δ
ted_sws/notice_packager/adapters/__init__.py 100.00% <100.00%> (ø)
ted_sws/notice_packager/adapters/archiver.py 100.00% <100.00%> (ø)
...sws/notice_packager/adapters/template_generator.py 100.00% <100.00%> (ø)
ted_sws/notice_packager/model/metadata.py 100.00% <100.00%> (ø)
ted_sws/notice_packager/resources/__init__.py 100.00% <100.00%> (ø)
...s/notice_packager/services/metadata_transformer.py 100.00% <100.00%> (ø)
...ed_sws/notice_packager/services/notice_packager.py 100.00% <100.00%> (ø)
ted_sws/adapters/config_resolver.py 75.60% <0.00%> (-21.96%) ⬇️
ted_sws/adapters/vault_secrets_store.py 94.28% <0.00%> (-2.86%) ⬇️
ted_sws/notice_packager/__init__.py 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0286ae3...7b10290. Read the comment docs.

Copy link
Collaborator

@costezki costezki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done.

See minor fixes requests in the comments.


from jinja2 import Environment, PackageLoader

TEMPLATES = Environment(loader=PackageLoader("ted_sws.notice_packager.resources", "templates"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be moved into the module

LIST_TYPE = List[PATH_TYPE]


class ArchiverABC(abc.ABC):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do not use the Fakes for testing, this abstraction is not needed.
But not harmful either.


class TemplateGenerator:
@classmethod
def __generate_template(cls, template, data: Dict = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use single and not double underscore marking for "private" functions.


@classmethod
def mets2action_mets_xml_generator(cls, data: Dict = None):
action = data["notice"]["action"]["type"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded dictionary keys are rarely a good idea

return cls.__generate_template(template, data)

@classmethod
def mets2action_mets_xml_generator(cls, data: Dict = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shall not use arbitrary dictionaries but domain classes to pass parameters and return values

raise ValueError('No such action: %s' % v)


class MetaMetadata(Metadata):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class can be merged into its parent

NORM_SEP = '_'


class MetadataTransformer:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic could have been implemented as a domain service. Alternatively it could have been integrated into the Package metadata.

return notice_metadata


def create_notice_package(in_data: IN_DATA_TYPE, rdf_content: Union[str, bytes] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is too long.

It could be broken down into a couple of smaller functions to ease the reading.

@kaleanych kaleanych merged commit 5f1d14b into main Mar 15, 2022
@costezki costezki deleted the feature/ted-51 branch March 18, 2022 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants