Merge lp:~robru/gwibber/account-manager into lp:~barry/gwibber/py3
Proposed by
Robert Bruce Park
Status: | Merged |
---|---|
Merged at revision: | 1422 |
Proposed branch: | lp:~robru/gwibber/account-manager |
Merge into: | lp:~barry/gwibber/py3 |
Diff against target: |
221 lines (+118/-22) 3 files modified
gwibber/Makefile (+10/-0) gwibber/gwibber/tests/test_account.py (+53/-17) gwibber/gwibber/utils/account.py (+55/-5) |
To merge this branch: | bzr merge lp:~robru/gwibber/account-manager |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Barry Warsaw | Pending | ||
Review via email: mp+123347@code.launchpad.net |
Description of the change
This branch adds AccountManager class in account.py, with code largely stolen directly from the old dispatcher. Some basic tests are added that cover its interaction with libaccounts and also with our streams.
Note that the AccountManager is not actually used anywhere yet, the intention is that it will be instantiated by the Dispatcher once that's in place. The reason for this is that it needs a callback into the Dispatcher's refresh() method in order to add new streams when new accounts have been added by libaccounts.
And just for fun, I've introduced a Makefile that makes it easier to invoke the testsuite, with or without virtualenv.
To post a comment you must log in.
On Sep 07, 2012, at 07:16 PM, Robert Bruce Park wrote:
>This branch adds AccountManager class in account.py, with code largely stolen
>directly from the old dispatcher. Some basic tests are added that cover its
>interaction with libaccounts and also with our streams.
Nice.
>Note that the AccountManager is not actually used anywhere yet, the intention
>is that it will be instantiated by the Dispatcher once that's in place. The
>reason for this is that it needs a callback into the Dispatcher's refresh()
>method in order to add new streams when new accounts have been added by
>libaccounts.
Sounds good.
>And just for fun, I've introduced a Makefile that makes it easier to invoke
>the testsuite, with or without virtualenv.
Very convenient!
Okay, code review coming up. Just in general, I added a bunch of comments
throughout based on my understanding of the changes. Once your branch is
merged please take a look to make sure I'm not mistaken.
=== added file 'gwibber/Makefile' site-packages -p python3 /tmp/gwib bin/python3 setup.py install bin/python3 -m unittest discover -vv
--- gwibber/Makefile 1970-01-01 00:00:00 +0000
+++ gwibber/Makefile 2012-09-07 19:15:22 +0000
> @@ -0,0 +1,10 @@
> +check:
> + python3 -m unittest discover -vv
> +
> +install:
> + python3 setup.py install
> +
> +check_all:
> + virtualenv --system-
> + /tmp/gwib/
> + /tmp/gwib/
This is great. I'm just going to add a standard copyright notice to the top
of the file.
=== modified file 'gwibber/ gwibber/ tests/test_ account. py' gwibber/ tests/test_ account. py 2012-09-06 20:48:07 +0000 gwibber/ tests/test_ account. py 2012-09-07 19:15:22 +0000
--- gwibber/
+++ gwibber/
> @@ -21,9 +21,12 @@
>
> import unittest
>
> +from gi.repository import Accounts
> +
Turns out this import isn't used, so I've removed it. Have you seen the
pyflakes tool? It's a nice little tool that finds some common mistakes in
Python code. It's not as thorough as others like pylint, but also doesn't
have the vast number of false positives that pylint can produce by default
(and which are a pita to suppress). Of course pylint integrates nicely with
Emacs so when it complains, it paints the line with a red background so it's
easy to see. It also displays the number of problems it finds in the
modeline.
For me, pyflakes strikes a nice balance for a static Python checker that gives
you useful warnings without bombarding you with false positives. A lot of
folks also like the pep8 tool, but since I co-authored that PEP, I tend to
have it's rules engraved in my brain, as you've no doubt unfortunately
observed in my curmudgeonly reviews. :)
> from gwibber.errors import UnsupportedProt ocolError protocols. flickr import Flickr utils.account import Account utils.account import Account, AccountManager manager. new_for_ service_ type( ).get_enabled_ account_ services. return_ value = []
> from gwibber.
> -from gwibber.
> +from gwibber.
> +
>
> try:
> # Python 3.3
> @@ -32,6 +35,30 @@
> import mock
>
>
> +accounts_manager = mock.Mock()
> +accounts_
> + 'microblogging'
> +
> +
> +class FakeAccount(dict):
> + global_id = 'some fake id'
> + def __init__(self, service):
> + self['id'] = 'faker/tha...