Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
added test for git sources in the get() method in snapcraft/sources.py #217
Conversation
|
Hello, thanks for your contribution. |
|
Who should I add as project manager? |
elopio
reviewed
Jan 11, 2016
| + for source in sources: | ||
| + with self.subTest(key=source): | ||
| + self.assertEqual( | ||
| + snapcraft.sources._get_source_type_from_uri(source), 'git') |
elopio
Jan 11, 2016
Member
In general we should try to avoid testing internal methods directly, and test that code through the exposed API. In this case, instead of testing _get_source_type_from_uri, it would be better to test through the get method. You'll have to patch the subprocess.check_call method so Git.pull doesn't contact the URL, and then just check the arguments passed to that check_call. Here are the details about patching: https://docs.python.org/3/library/unittest.mock.html
I like the scenarios and the subTest.
|
The project manager is Oliver Ries. |
|
Done. I made the change, pushed, squashed the commits, then force pushed. |
elopio
reviewed
Jan 11, 2016
| + builddir = 'testbuilddir', | ||
| + options = options) | ||
| + | ||
| + mock_pull.assert_called_with() |
|
@fazerlicourice7 you're missing the bug bits mentioned in the contribution guide @elopio linked to above. |
elopio
reviewed
Jan 11, 2016
| + self.source_type = source_type | ||
| + self.source_branch = source_branch | ||
| + self.source_tag = source_tag | ||
| + self.source_subdir = source_subdir |
elopio
Jan 11, 2016
Member
Instead of duplicating the code, it would be nice if you move the one from test_base_plugin to snapcraft/tests.py and use it like tests.MockOptions.
fazerlicourice7
Jan 11, 2016
Contributor
Where do you want me to move it? snapcraft/tests.py doesn't seem to exist.
elopio
reviewed
Jan 11, 2016
| + for source in sources: | ||
| + with self.subTest(key=source): | ||
| + | ||
| + options = MockOptions(source=source,source_type='git') |
elopio
Jan 11, 2016
Member
Here you will have a pep8 error because you are missing a space after the comma.
elopio
reviewed
Jan 11, 2016
| + with self.subTest(key=source): | ||
| + | ||
| + options = MockOptions(source=source,source_type='git') | ||
| + local = snapcraft.sources |
elopio
Jan 11, 2016
Member
I don't understand why do you need this alias. I would prefer to just call snapcraft.sources.get.
elopio
reviewed
Jan 11, 2016
| + local = snapcraft.sources | ||
| + local.get( | ||
| + sourcedir = 'testsourcedir', | ||
| + builddir = 'testbuilddir', |
elopio
Jan 11, 2016
Member
since now the sourcedir and builddir are not used in the test, a good practices is to make it explicit that they are dummies (http://xunitpatterns.com/Dummy%20Object.html)
So, please change them like this:
sourcedir = 'dummy',
builddir = 'dummy'
|
Verified that CLA has been signed. |
|
@fazerlicourice7 awesome! Final change request from my side: Copyright (C) 2015, 2016 Canonical Ltd Thanks a lot! |
fazerlicourice7
changed the title from
added test for git sources in the _get_source_type_from_uri() method
to
added test for git sources in the get() method in snapcraft/sources.py
Jan 11, 2016
|
Why are these checks failing? |
|
Click on
|
|
How can I remove the previous two commits? My earlier one and the one from sergiusens? Every time I try something, something gets messed up. |
|
@fazerlicourice7 assuming you're happy with where your PR is now, you can (and should, if you're following our contribution guide) squash them all down into one well-formatted commit. To do that, get on your branch and run
Read the comments at the bottom of the editor-- they're helpful. What you want to do is take these three commits and "squash" them into one. So let's squash the last two into the first-- edit it to look like this:
Now save and exit the editor, the rebase will run, and it'll pop up another editor window asking you for a commit message for your new squashed commit. You'll notice that it fills the editor with the commit messages from the other three-- clean those up and make it one cohesive commit message. Then save and exit, and the rebase will finish. If you run |
kyrofa
and others
added some commits
Jan 6, 2016
fazerlicourice7
closed this
Jan 14, 2016
|
I give up with the git squashing stuff. I'm just going to do it all over again. |
fazerlicourice7 commentedJan 10, 2016
No description provided.