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

A brand new API - pyteamcity.future #37

Merged
merged 36 commits into from
Aug 10, 2016
Merged

A brand new API - pyteamcity.future #37

merged 36 commits into from
Aug 10, 2016

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Aug 4, 2016

Goal here is to create a brand new API in pyteamcity.future that is much more flexible and to have nicer code that is easier to work with. The old code encourages adding a zillion methods for different ways of filtering. The new code has an API with a smaller number of methods that are more consistent and more flexible in terms of filtering. It is modeled loosely after the Django ORM API.

The plan is to make this available as pyteamcity.future for a few releases while still retaining the old legacy API as pyteamcity, so existing code using that API still works. Then after a few releases, I would remove the legacy API and rename pyteamcity.future to pyteamcity and it would be the only supported API.

msabramo added a commit that referenced this pull request Aug 4, 2016
Add missing `import requests` and use `UnauthorizedError` from
our `exceptions` module
TEAMCITY_HOST
TEAMCITY_USER
TEAMCITY_PASSWORD
commands = py.test {posargs:-v --cov=pyteamcity --cov-report=term-missing test_pyteamcity.py pyteamcity/future/tests/unit/}
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest only having py.test here and moving the rest in pytest.ini (and move the path under testpaths, not addopts). This way one can just type py.test without running tox and it will behave the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh cool! Glad to have you looking at this, @aconrad!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! See e0de037

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

to make it clearer that it's legacy and probably won't be further
developed.
Allows getting server info like web_url, version, etc.
def server_info(self):
url = self.base_url + '/app/rest/server'
res = self.session.get(url)
res.raise_for_status()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't you want to wrap this into your own exception instead of exposing the exception of the underlying http library (requests)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. Only problem is there are so many possible HTTP errors and I hate to have to create my own exception for each one.

Copy link
Contributor

Choose a reason for hiding this comment

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

You already have HTTPError, don't you? You can use this as your base exception for all http exceptions. Later, if you find yourself needing to expose more specific http errors then you can create new exceptions that inherit HTTPError -- this won't be backwards incompatible for existing user code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Went ahead and did this in d9967bb. Thanks!

msabramo and others added 3 commits August 4, 2016 12:32
* .travis.yml: Post coverage to couverture.io

* .travis.yml: Skip couverture for flake8 builds
so this is not blank file, which might be confusing couverture.io?
@aconrad
Copy link
Contributor

aconrad commented Aug 5, 2016

@msabramo I think I fixed the issue we were running into, please let me know if you see anything else not behaving properly with regards to coverage.

@msabramo
Copy link
Contributor Author

msabramo commented Aug 5, 2016

Thanks, @aconrad!

env | sort
if [ "$TOXENV" == "flake8" ]; then
return
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also test for the presence of a coverage.xml file, that would scale better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's even better. Maybe we should put this in a separate shell script like couverture.sh? Maybe couverture could offer a link to download one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'm thinking about doing this eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@msabramo msabramo changed the title WIP: A brand new API A brand new API Aug 10, 2016
@msabramo msabramo changed the title A brand new API A brand new API - pyteamcity.future Aug 10, 2016
@msabramo msabramo merged commit c06ddef into master Aug 10, 2016
@msabramo msabramo deleted the future branch August 10, 2016 16:09
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

2 participants