# -*- coding: utf-8 -*-

# Copyright(C) 2014      Bezleputh
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.


from weboob.tools.test import BackendTest


class TwitterTest(BackendTest):
    BACKEND = 'twitter'

    def test_twitter(self):
        l = list(self.backend.iter_threads())
        assert len(l)
        thread = self.backend.get_thread(l[0].id)
        assert len(thread.root.content)

@@ -724,16 +724,54 @@
 ses/%3E.%0A%0A
+from nose.plugins.skip import SkipTest
 %0Afrom we
@@ -805,16 +805,67 @@
 endTest%0A
+from weboob.capabilities.base import CapBaseObject%0A
 %0A%0Aclass 
@@ -939,16 +939,23 @@
 tter
+_logged
 (self):%0A
     
@@ -950,16 +950,261 @@
 (self):%0A
+        if self.backend.browser.username:%0A            assert(self.backend.browser.get_me())%0A        else:%0A            raise SkipTest(%22User credentials not defined%22)%0A%0A    def test_twitter_list(self):%0A        if self.backend.browser.username:%0A    
         
@@ -1237,24 +1237,28 @@
 _threads())%0A
+    
         asse
@@ -1275,16 +1275,20 @@
         
+    
 thread =
@@ -1321,16 +1321,1469 @@
 %5B0%5D.id)%0A
+            assert len(thread.root.content)%0A        else:%0A            raise SkipTest(%22User credentials not defined%22)%0A%0A    def test_ls_me(self):%0A        if self.backend.browser.username:%0A            l = list(self.backend.iter_resources(%5BCapBaseObject%5D, %5B'me'%5D))%0A            assert len(l)%0A            thread = self.backend.get_thread(l%5B0%5D.id)%0A            assert len(thread.root.content)%0A        else:%0A            raise SkipTest(%22User credentials not defined%22)%0A%0A    def test_ls_search(self):%0A        l = list(self.backend.iter_resources(%5BCapBaseObject%5D, %5B'search', 'weboob'%5D))%0A        assert len(l)%0A        thread = self.backend.get_thread(l%5B0%5D.id)%0A        assert len(thread.root.content)%0A%0A    def test_ls_hashtag(self):%0A        l = list(self.backend.iter_resources(%5BCapBaseObject%5D, %5B'hashtags', 'weboob'%5D))%0A        assert len(l)%0A        thread = self.backend.get_thread(l%5B0%5D.id)%0A        assert len(thread.root.content)%0A%0A    def test_ls_profils(self):%0A        l = list(self.backend.iter_resources(%5BCapBaseObject%5D, %5B'profils', 'jf_cope'%5D))%0A        assert len(l)%0A        thread = self.backend.get_thread(l%5B0%5D.id)%0A        assert len(thread.root.content)%0A%0A    def test_ls_trend(self):%0A        l = list(self.backend.iter_resources(%5BCapBaseObject%5D, %5B'trendy'%5D))%0A        assert len(l)%0A        l1 = list(self.backend.iter_resources(%5BCapBaseObject%5D, %5B'trendy', u'%25s' %25 l%5B0%5D.split_path%5B0%5D%5D))%0A        assert len(l1)%0A        thread = self.backend.get_thread(l1%5B0%5D.id)%0A
         

improve tests