1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/python
import os
import sys
import unittest
sys.path.insert(0,"../")
class TestGwibber(unittest.TestCase):
""" tests the "where is it in the menu" code """
def setUp(self):
pass
def test_gwibber_helper_mock(self):
from softwarecenter.gwibber_helper import GwibberHelperMock
os.environ["SOFTWARE_CENTER_GWIBBER_MOCK_USERS"] = "2"
os.environ["SOFTWARE_CENTER_GWIBBER_MOCK_NO_FAIL"] = "1"
gh = GwibberHelperMock()
accounts = gh.accounts()
self.assertEqual(len(accounts), 2)
#print accounts
# we can not test the real gwibber here, otherwise it will
# post our test data to real services
self.assertEqual(gh.send_message ("test"), True)
def test_gwibber_helper(self):
from softwarecenter.gwibber_helper import GwibberHelper
# readonly test as there maybe be real accounts
gh = GwibberHelper()
have_accounts = gh.has_accounts_in_sqlite()
self.assertTrue(isinstance(have_accounts, bool))
accounts = gh.accounts()
self.assertTrue(isinstance(accounts, list))
def not_working_because_gi_does_not_provide_list_test_gwibber(self):
from gi.repository import Gwibber
#service = Gwibber.Service()
#service.quit()
# get account data
accounts = Gwibber.Accounts()
print dir(accounts)
#print "list: ", accounts.list()
# check single account for send enabled, only do if "True"
#print accounts.send_enabled(accounts.list[0])
# first check gwibber available
service = Gwibber.Service()
print dir(service)
service.service_available(False)
service.send_message ("test")
if __name__ == "__main__":
import logging
logging.basicConfig(level=logging.DEBUG)
unittest.main()
|