Пример #1
0
 def setup_class(self, monkeypatch):
     self.acc_id = "dummy-twitter"
     self.core = Core(load_accounts=False)
     self.account = Account.new("twitter", "dummy")
     self.account.columns = [Column(self.account.id_, ColumnType.TIMELINE)]
     self.account2 = Account.new("twitter", "qux")
     self.account2.columns = [Column(self.account2.id_, ColumnType.TIMELINE)]
     self.all_accounts = [self.account, self.account2]
     monkeypatch.setattr(self.core.accman, "get", lambda x: self.account)
Пример #2
0
    def test_is_account_logged_in(self, monkeypatch):
        account = Account.new("twitter")
        monkeypatch.setattr(self.core.accman, "get", lambda x: account)

        account.logged_in = False
        response = self.core.is_account_logged_in("foo")
        assert response == False

        account.logged_in = True
        response = self.core.is_account_logged_in("foo")
        assert response == True
Пример #3
0
    def test_get_all_friends_list(self, monkeypatch):
        account = Account.new("twitter")
        accounts = [account]
        profile = Profile()
        profile.username = "******"
        result = [profile]

        monkeypatch.setattr(self.core.accman, "accounts", lambda: accounts)
        monkeypatch.setattr(account, "get_following", lambda: result)

        friends = self.core.get_all_friends_list()
        assert isinstance(friends, list)
        assert friends[0], "dummy"
Пример #4
0
def register_account(username):
    account = build_account_id(username)
    if account in accounts:
        print 'Your account is already registered. Nothing to do'
    else:
        new_access = Account.new('twitter')
        url = new_access.request_oauth_access()
        print "Please go to the following URL, log-in and allow access for libturpial. Then write the PIN in here."
        print url
        cod = raw_input('PIN:')
        new_access.authorize_oauth_access(cod)
        core.register_account(new_access)
        print "Account {access_id} registered successfully".format(access_id=new_access.id_)
Пример #5
0
    def test_has_stored_passwwd(self, monkeypatch):
        account = Account.new("twitter")
        profile = Profile()
        profile.username = "******"
        account.profile = profile

        monkeypatch.setattr(self.core.accman, "get", lambda x: account)

        profile.password = None
        response = self.core.has_stored_passwd("foo")
        assert response == False

        profile.password = ''
        response = self.core.has_stored_passwd("foo")
        assert response == False

        profile.password = '******'
        response = self.core.has_stored_passwd("foo")
        assert response == True
Пример #6
0
 def test_accounts(self, monkeypatch):
     account2 = Account.new("twitter", "bar")
     accounts = {self.account.id_: self.account, 'bar-twitter': account2}
     monkeypatch.setattr(self.accman, '_AccountManager__accounts', accounts)
     assert account2 in self.accman.accounts()
Пример #7
0
 def test_list(self, monkeypatch):
     account2 = Account.new("twitter", "bar")
     accounts = {self.account.id_: self.account, 'bar-twitter': account2}
     monkeypatch.setattr(self.accman, '_AccountManager__accounts', accounts)
     assert self.accman.list() == ['bar-twitter', 'foo-twitter']
Пример #8
0
 def setup_class(self, monkeypatch):
     config = AppConfig()
     self.account = Account.new("twitter", "foo")
     self.accman = AccountManager(config, load=False)
Пример #9
0
 def test_accounts(self, monkeypatch):
     account2 = Account.new("twitter", "bar")
     accounts = {self.account.id_: self.account, 'bar-twitter': account2}
     monkeypatch.setattr(self.accman, '_AccountManager__accounts', accounts)
     assert account2 in self.accman.accounts()
Пример #10
0
                    choices=core.list_protocols(), help="Protocol",
                    required=True)
parser.add_argument("-m", "--message", dest="message", help="Message",
                    required=True)
args = parser.parse_args()


username = args.username
protocol = args.protocol
account_pattern = "-".join([username, protocol])
message = args.message

print "Trying to send message '%s'\nas user: %s, protocol: %s" % (message,
                                                                  username,
                                                                  protocol)

if account_pattern in core.list_accounts():
    core.update_status(account_pattern, message)
else:
    # If account is not already registered in libturpial,
    # access must be granted:
    account = Account.new(protocol)
    url = account.request_oauth_access()
    instructions = "Please go to the following URL, log-in and allow access" \
                   " for libturpial. Then write the PIN in here."
    print "%s\n%s" % (instructions, url)
    cod = raw_input("PIN: ")
    account.authorize_oauth_access(cod)
    account_id = core.register_account(account)
    core.update_status(account_id, message)
Пример #11
0
 def test_list(self, monkeypatch):
     account2 = Account.new("twitter", "bar")
     accounts = {self.account.id_: self.account, 'bar-twitter': account2}
     monkeypatch.setattr(self.accman, '_AccountManager__accounts', accounts)
     assert self.accman.list() == ['bar-twitter', 'foo-twitter']
Пример #12
0
 def setup_class(self, monkeypatch):
     config = AppConfig()
     self.account = Account.new("twitter", "foo")
     self.accman = AccountManager(config, load=False)
Пример #13
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Libturpial usage example
# 
# Author: Carlos Guerrero <*****@*****.**>
# 24 June 2013


from libturpial.api.models.account import Account
from libturpial.api.core import Core

account = "username-twitter" #Replace <username> with the user you want to send tweet with
message = "Tweet sent using Libturpial"

c = Core()
accounts = c.list_accounts()

if account in accounts:
    c.update_status(account,message)
else:
    #If account is not already registered in libturpial, acces must be granted:
    a = Account.new('twitter') #you can also create identi.ca accounts
    url = a.request_oauth_access()
    print "Please go to the following URL, log-in and allow access for Libturpial. Then write the PIN in here."
    print url
    cod = raw_input("PIN:")
    a.authorize_oauth_access(cod)
    c.register_account(a)
Пример #14
0
 def test_new(self):
     account = Account.new('twitter', 'foo')
     assert isinstance(account, Account)
Пример #15
0
 def test_new(self):
     account = Account.new('twitter', 'foo')
     assert isinstance(account, Account)