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

python plugin: record manifest #1487

Merged
merged 9 commits into from
Aug 22, 2017
Merged

Conversation

come-maiz
Copy link
Contributor

No description provided.

@mock.patch.object(python.PythonPlugin, 'run')
def test_pull_with_nothing(self, mock_run):
def test_pull_with_nothing(self, mock_run, mock_run_output):
mock_run_output.side_effect = fake_empty_pip_list
Copy link
Contributor

Choose a reason for hiding this comment

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

This can/should be done in the @mock.patch.object line - e.g. @mock.patch.object(python.PythonPlugin, 'run_output', side_effect=fake_empty_pip_list)

Makes a clearer distinction between your fixture and the actual test

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like sane advice. I just reviewed another PR where I made a comment about it getting complicated on reviewing what we want to test versus the setup for that and the resulting verification. This is a big thing for tests that have complicated fixtures to setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good suggestion. Thanks!

@sergiusens
Copy link
Collaborator

It feels like storing the requirements file is almost informational now, isn't it?

Given that we record the exact packages to install and can potentially use constraints to avoid some weird behaviour (unbeknownst to us) of pip picking packages outside of what was locked down. I guess the reason we store requirements files is in case it is something external to the sources of the project.

I don't have any critique here, just thinking out loud as this has prevented me from reviewing properly since I first saw the PR Monday night.

@sergiusens
Copy link
Collaborator

Since testing was brought up, now that we are using testtools, I much prefer

self.assertThat(output, Equals(expected)

instead of

self.assertEqual(output, expected)

since in the latter when writing (made easier with good variable naming) or executing it is never clear what is what you wanted versus what you got.

@kyrofa
Copy link
Contributor

kyrofa commented Aug 17, 2017

I much prefer

self.assertThat(output, Equals(expected)

instead of

self.assertEqual(output, expected)

since in the latter when writing (made easier with good variable naming) or executing it is never clear what is what you wanted versus what you got.

Agreed, especially when you consider that, with testtools, it's assertEqual(expected, actual) where order matters. All of the tests we wrote before the switch had it the other way around, since order didn't matter.

@come-maiz
Copy link
Contributor Author

Alright, thanks for the reviews!
I updated the decorator, assertThat, and modified the code to only record the file contents if they are remote.
Please take another look.

@@ -131,6 +131,10 @@ def clean_build(self):
"""Clean the artifacts that resulted from building this part."""
pass

def get_manifest(self):
"""Return the information to record after the build of this part."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the return value here need to be a dict? Documenting expectations here would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that would be very good.
We haven't finished discussing about docstrings. How do you imagine this? As prose, or just an rtype sphinx tag?
I added :rtype: dict, let me know what do you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

The prose you have in addition to rtype is excellent.

Copy link
Contributor

@kyrofa kyrofa left a comment

Choose a reason for hiding this comment

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

Looks good to me now.

Copy link
Collaborator

@sergiusens sergiusens left a comment

Choose a reason for hiding this comment

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

Looks good, but please improve the check for locality of requirements txt in new PR, this should be implemented in sources to verify a file is actually committed into the VCS

installed_pipy_packages = self._run_pip(setup_file)
# We record the requirements and constraints files only if they are
# remote. If they are local, they are already tracked with the source.
if self.options.requirements and isurl(self.options.requirements):
Copy link
Collaborator

Choose a reason for hiding this comment

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

this check need improvement as != url does not imply it is part of the source. You can do this in a follow up PR though.

@sergiusens
Copy link
Collaborator

Fixes #1454

@sergiusens sergiusens merged commit 5887a82 into canonical:master Aug 22, 2017
kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Sep 21, 2017
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.

None yet

4 participants