#6 Refactor for more extensibility, complete test coverage
Merged by jcline. Opened by adamwill.
adamwill/cloud-image-uploader refactor-callable  into  main

The first commit in this series is a significant refactor of the code to make it more extensible. It allows for the addition of arbitrary extra 'handlers'. We can use this to handle other cloud images and we also intend to use it to handle publishing container images to registries, replacing the bash scripts currently used for that purpose.

The subsequent commits extend the test suite to reach 100% coverage, which seems like a good prelude to adding further handlers.

Tiny nit, I think since this produces a class it's clearer to use the normal class naming rules. I also think it's okay to not mark it as internal, particularly since if someone is using this module like a library... well, we're not making any effort at having that work.

It seems you can specify type hints by defining things this way, which I think is helpful:

from typing import NamedTuple
class ReleaseInfo(NamedTuple):
    fedfind_release: ff_release.Release
    release_number: int   # not sure if this is true, maybe str is fine.
    end_of_life: datetime.datetime   # not sure if this is true, maybe str is fine.

Does this function ever raise UnsupportedComposeError? It seems like it wouldn't, but Python makes it so hard to tell.

If it isn't expected to, it might be better to move it out of the try/except block.

I noted a couple minor things, but nothing that'd stop me from taking it as is if you disagree. This looks like a great improvement, thank you!

rebased onto 3776a6f0fe610b0f1246791c8cb0be556b8bb24b

Thanks, adjusted both of those. I kept the existing names of the properties for the ReleaseInfo namedtuple, though, I think they're sufficiently verbose while requiring less typing and keeping line lengths short...if you'd really prefer very_long_and_expressive_variable_names I can tweak it again. :D

rebased onto e9ee3cf0b3649a99629120ade12f8ed412ff674f

I don't see a cassette for this test and it's failing trying to connect to localhost:5001 which makes me think some test setup got lost.

oh, I guess I forgot to git add the cassette. fixed.

9 new commits added

  • Add a test for download_image
  • Add a test of Consumer's handling of Handler exceptions
  • Add a test of messages we intentionally don't handle
  • Add a test for the cases where we skip Azure images
  • Add a test of the ansible playbook run failure path
  • Add a test of get_relinfo (to cover the EOL synthesis)
  • Add test to cover failure to reach Bodhi
  • Mark test_old_unsupported_azure_compose for VCR
  • Refactor for better extensibility

the plan there is that, once this PR is merged, we change that URL to point to the copy in the repo itself, and retake the cassette. but we can't do that till the PR is merged. catch 22 situation.

Okay. It's not like there's CI to break anyway so...

Pull-Request has been merged by jcline