D-Bus testing: add testGetReportsByRef in TestSessionAPIsDummy
Test Session.GetReports by reference files. The idea is to GetReports from the reference sessions files so that we could know the expected results. It could do extractly comparsions. To achieve the goal, 1) create 5 directories of sessions files 2) copy reference files from 'test/test-dbus/cache' to current xdg cache directory 'test-dbus/cache'. 3) calling 'GetReports' and compare returned results with expected value. This unit test covers below cases of GetReports: 1) start=0, index=0 2) start=0, index=1 3) start=0, index=0xFFFFFFFF 4) start=2, index=0xFFFFFFFF 5) start=5, index=0xFFFFFFFF The case 4) will cause an integer overflow issue. Thus nothing is returned, which is not expected. The fix for this will be in the next commit.
This commit is contained in:
parent
423fc0378f
commit
896246acf4
|
@ -901,6 +901,81 @@ class TestSessionAPIsDummy(unittest.TestCase, DBusUtil):
|
|||
reports = self.session.GetReports(0xFFFFFFFF, 0xFFFFFFFF, utf8_strings=True)
|
||||
self.failUnlessEqual(reports, [])
|
||||
|
||||
def testGetReportsByRef(self):
|
||||
""" Test the reports are gotten correctly from reference files. Also covers boundaries """
|
||||
""" This could be extractly compared since the reference files are known """
|
||||
self.setupFiles()
|
||||
report0 = { "source-addressbook-stat-local-any-sent" : "9168",
|
||||
"source-addressbook-stat-remote-added-total" : "71",
|
||||
"source-addressbook-stat-remote-updated-total" : "100",
|
||||
"source-addressbook-stat-local-updated-total" : "632",
|
||||
"source-addressbook-stat-remote-any-reject" : "100",
|
||||
"source-addressbook-stat-remote-any-conflict_duplicated" : "5293487",
|
||||
"source-addressbook-stat-remote-any-conflict_client_won" : "33",
|
||||
"source-addressbook-stat-local-any-received" : "2",
|
||||
"source-addressbook-stat-local-removed-total" : "4",
|
||||
"source-addressbook-stat-remote-any-conflict_server_won" : "38",
|
||||
"source-addressbook-stat-local-any-reject" : "77",
|
||||
"source-addressbook-stat-local-added-total" : "84",
|
||||
"source-addressbook-stat-remote-removed-total" : "66",
|
||||
"source-calendar-stat-local-any-sent" : "8619",
|
||||
"source-calendar-stat-remote-added-total": "17",
|
||||
"source-calendar-stat-remote-updated-total" : "10",
|
||||
"source-calendar-stat-local-updated-total" : "6",
|
||||
"source-calendar-stat-remote-any-reject" : "1",
|
||||
"source-calendar-stat-remote-any-conflict_duplicated" : "5",
|
||||
"source-calendar-stat-remote-any-conflict_client_won" : "3",
|
||||
"source-calendar-stat-local-any-received" : "24",
|
||||
"source-calendar-stat-local-removed-total" : "54",
|
||||
"source-calendar-stat-remote-any-conflict_server_won" : "38",
|
||||
"source-calendar-stat-local-any-reject" : "7",
|
||||
"source-calendar-stat-local-added-total" : "42",
|
||||
"source-calendar-stat-remote-removed-total" : "6",
|
||||
"source-memo-stat-local-any-sent" : "8123",
|
||||
"source-memo-stat-remote-added-total" : "15",
|
||||
"source-memo-stat-remote-updated-total" : "6",
|
||||
"source-memo-stat-local-updated-total" : "8",
|
||||
"source-memo-stat-remote-any-reject" : "16",
|
||||
"source-memo-stat-remote-any-conflict_duplicated" : "27",
|
||||
"source-memo-stat-remote-any-conflict_client_won" : "2",
|
||||
"source-memo-stat-local-any-received" : "3",
|
||||
"source-memo-stat-local-removed-total" : "4",
|
||||
"source-memo-stat-remote-any-conflict_server_won" : "8",
|
||||
"source-memo-stat-local-any-reject" : "40",
|
||||
"source-memo-stat-local-added-total" : "34",
|
||||
"source-memo-stat-remote-removed-total" : "5",
|
||||
"source-todo-stat-local-any-sent" : "619",
|
||||
"source-todo-stat-remote-added-total" : "71",
|
||||
"source-todo-stat-remote-updated-total" : "1",
|
||||
"source-todo-stat-local-updated-total" : "9",
|
||||
"source-todo-stat-remote-any-reject" : "10",
|
||||
"source-todo-stat-remote-any-conflict_duplicated" : "15",
|
||||
"source-todo-stat-remote-any-conflict_client_won" : "7",
|
||||
"source-todo-stat-local-any-received" : "2",
|
||||
"source-todo-stat-local-removed-total" : "4",
|
||||
"source-todo-stat-remote-any-conflict_server_won" : "8",
|
||||
"source-todo-stat-local-any-reject" : "3",
|
||||
"source-todo-stat-local-added-total" : "24",
|
||||
"source-todo-stat-remote-removed-total" : "80" }
|
||||
reports = self.session.GetReports(0, 0, utf8_strings=True)
|
||||
self.failUnlessEqual(reports, [])
|
||||
# get only one report
|
||||
reports = self.session.GetReports(0, 1, utf8_strings=True)
|
||||
self.assertTrue(len(reports) == 1)
|
||||
self.failUnlessEqual(reports[0], report0)
|
||||
""" the number of reference sessions is totally 5. Check the returned count
|
||||
when parameter is bigger than 5 """
|
||||
reports = self.session.GetReports(0, 0xFFFFFFFF, utf8_strings=True)
|
||||
self.assertTrue(len(reports) == 5)
|
||||
# start from 2, this could check integer overflow
|
||||
reports2 = self.session.GetReports(2, 0xFFFFFFFF, utf8_strings=True)
|
||||
self.assertTrue(len(reports2) == 3)
|
||||
# the first element of reports2 should be the same as the third element of reports
|
||||
self.failUnlessEqual(reports[2], reports2[0])
|
||||
# indexed from 5, nothing could be gotten
|
||||
reports = self.session.GetReports(5, 0xFFFFFFFF, utf8_strings=True)
|
||||
self.failUnlessEqual(reports, [])
|
||||
|
||||
class TestSessionAPIsReal(unittest.TestCase, DBusUtil):
|
||||
""" This class is used to test those unit tests of session APIs, depending on doing sync.
|
||||
Thus we need a real server configuration to confirm sync could be run successfully.
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
start = 1258519955, 2009-11-18 12:11:35 +0800
|
||||
end = 1258519964, 2009-11-18 12:11:44 +0800
|
||||
status = 200
|
||||
source-addressbook-mode = slow
|
||||
source-addressbook-first = true
|
||||
source-addressbook-resume = false
|
||||
source-addressbook-status = 0
|
||||
source-addressbook-backup-before = 0
|
||||
source-addressbook-backup-after = 0
|
||||
source-addressbook-stat-local-any-sent = 9168
|
||||
source-addressbook-stat-remote-added-total = 71
|
||||
source-addressbook-stat-remote-updated-total = 100
|
||||
source-addressbook-stat-local-updated-total = 632
|
||||
source-addressbook-stat-remote-any-reject = 100
|
||||
source-addressbook-stat-remote-any-conflict_duplicated = 5293487
|
||||
source-addressbook-stat-remote-any-conflict_client_won = 33
|
||||
source-addressbook-stat-local-any-received = 2
|
||||
source-addressbook-stat-local-removed-total = 4
|
||||
source-addressbook-stat-remote-any-conflict_server_won = 38
|
||||
source-addressbook-stat-local-any-reject = 77
|
||||
source-addressbook-stat-local-added-total = 84
|
||||
source-addressbook-stat-remote-removed-total = 66
|
||||
source-calendar-mode = slow
|
||||
source-calendar-first = true
|
||||
source-calendar-resume = false
|
||||
source-calendar-status = 0
|
||||
source-calendar-backup-before = 17
|
||||
source-calendar-backup-after = 17
|
||||
source-calendar-stat-local-any-sent = 8619
|
||||
source-calendar-stat-remote-added-total = 17
|
||||
source-calendar-stat-remote-updated-total = 10
|
||||
source-calendar-stat-local-updated-total = 6
|
||||
source-calendar-stat-remote-any-reject = 1
|
||||
source-calendar-stat-remote-any-conflict_duplicated = 5
|
||||
source-calendar-stat-remote-any-conflict_client_won = 3
|
||||
source-calendar-stat-local-any-received = 24
|
||||
source-calendar-stat-local-removed-total = 54
|
||||
source-calendar-stat-remote-any-conflict_server_won = 38
|
||||
source-calendar-stat-local-any-reject = 7
|
||||
source-calendar-stat-local-added-total = 42
|
||||
source-calendar-stat-remote-removed-total = 6
|
||||
source-memo-mode = slow
|
||||
source-memo-first = true
|
||||
source-memo-resume = false
|
||||
source-memo-status = 0
|
||||
source-memo-backup-before = 3
|
||||
source-memo-backup-after = 4
|
||||
source-memo-stat-local-any-sent = 8123
|
||||
source-memo-stat-remote-added-total = 15
|
||||
source-memo-stat-remote-updated-total = 6
|
||||
source-memo-stat-local-updated-total = 8
|
||||
source-memo-stat-remote-any-reject = 16
|
||||
source-memo-stat-remote-any-conflict_duplicated = 27
|
||||
source-memo-stat-remote-any-conflict_client_won = 2
|
||||
source-memo-stat-local-any-received = 3
|
||||
source-memo-stat-local-removed-total = 4
|
||||
source-memo-stat-remote-any-conflict_server_won = 8
|
||||
source-memo-stat-local-any-reject = 40
|
||||
source-memo-stat-local-added-total = 34
|
||||
source-memo-stat-remote-removed-total = 5
|
||||
source-todo-mode = slow
|
||||
source-todo-first = true
|
||||
source-todo-resume = false
|
||||
source-todo-status = 0
|
||||
source-todo-backup-before = 2
|
||||
source-todo-backup-after = 2
|
||||
source-todo-stat-local-any-sent = 619
|
||||
source-todo-stat-remote-added-total = 71
|
||||
source-todo-stat-remote-updated-total = 1
|
||||
source-todo-stat-local-updated-total = 9
|
||||
source-todo-stat-remote-any-reject = 10
|
||||
source-todo-stat-remote-any-conflict_duplicated = 15
|
||||
source-todo-stat-remote-any-conflict_client_won = 7
|
||||
source-todo-stat-local-any-received = 2
|
||||
source-todo-stat-local-removed-total = 4
|
||||
source-todo-stat-remote-any-conflict_server_won = 8
|
||||
source-todo-stat-local-any-reject = 3
|
||||
source-todo-stat-local-added-total = 24
|
||||
source-todo-stat-remote-removed-total = 80
|
|
@ -0,0 +1,41 @@
|
|||
start = 1258520155, 2009-11-18 12:11:55 +0800
|
||||
end = 1258520165, 2009-11-18 12:11:05 +0800
|
||||
status = 200
|
||||
source-addressbook-mode = slow
|
||||
source-addressbook-first = true
|
||||
source-addressbook-resume = false
|
||||
source-addressbook-status = 0
|
||||
source-addressbook-backup-before = 0
|
||||
source-addressbook-backup-after = 2
|
||||
source-addressbook-stat-local-added-total = 2
|
||||
source-addressbook-stat-local-any-received = 922
|
||||
source-calendar-mode = slow
|
||||
source-calendar-first = true
|
||||
source-calendar-resume = false
|
||||
source-calendar-status = 0
|
||||
source-calendar-backup-before = 17
|
||||
source-calendar-backup-after = 18
|
||||
source-calendar-stat-local-added-total = 1
|
||||
source-calendar-stat-local-any-sent = 8619
|
||||
source-calendar-stat-local-any-received = 267
|
||||
source-calendar-stat-remote-added-total = 17
|
||||
source-memo-mode = slow
|
||||
source-memo-first = true
|
||||
source-memo-resume = false
|
||||
source-memo-status = 0
|
||||
source-memo-backup-before = 4
|
||||
source-memo-backup-after = 5
|
||||
source-memo-stat-local-added-total = 1
|
||||
source-memo-stat-local-any-sent = 96
|
||||
source-memo-stat-local-any-received = 14
|
||||
source-memo-stat-remote-added-total = 4
|
||||
source-todo-mode = slow
|
||||
source-todo-first = true
|
||||
source-todo-resume = false
|
||||
source-todo-status = 0
|
||||
source-todo-backup-before = 2
|
||||
source-todo-backup-after = 3
|
||||
source-todo-stat-local-added-total = 1
|
||||
source-todo-stat-local-any-sent = 756
|
||||
source-todo-stat-local-any-received = 259
|
||||
source-todo-stat-remote-added-total = 2
|
|
@ -0,0 +1,39 @@
|
|||
start = 1258520273, 2009-11-18 12:11:53 +0800
|
||||
end = 1258520283, 2009-11-18 12:11:03 +0800
|
||||
status = 200
|
||||
source-addressbook-mode = slow
|
||||
source-addressbook-first = true
|
||||
source-addressbook-resume = false
|
||||
source-addressbook-status = 0
|
||||
source-addressbook-backup-before = 1
|
||||
source-addressbook-backup-after = 2
|
||||
source-addressbook-stat-local-added-total = 1
|
||||
source-addressbook-stat-local-any-sent = 384
|
||||
source-addressbook-stat-local-any-received = 492
|
||||
source-addressbook-stat-remote-added-total = 1
|
||||
source-calendar-mode = slow
|
||||
source-calendar-first = true
|
||||
source-calendar-resume = false
|
||||
source-calendar-status = 0
|
||||
source-calendar-backup-before = 18
|
||||
source-calendar-backup-after = 18
|
||||
source-calendar-stat-local-any-sent = 9012
|
||||
source-calendar-stat-remote-added-total = 18
|
||||
source-memo-mode = slow
|
||||
source-memo-first = true
|
||||
source-memo-resume = false
|
||||
source-memo-status = 0
|
||||
source-memo-backup-before = 5
|
||||
source-memo-backup-after = 6
|
||||
source-memo-stat-local-added-total = 1
|
||||
source-memo-stat-local-any-sent = 136
|
||||
source-memo-stat-local-any-received = 14
|
||||
source-memo-stat-remote-added-total = 5
|
||||
source-todo-mode = slow
|
||||
source-todo-first = true
|
||||
source-todo-resume = false
|
||||
source-todo-status = 0
|
||||
source-todo-backup-before = 3
|
||||
source-todo-backup-after = 3
|
||||
source-todo-stat-local-any-sent = 1141
|
||||
source-todo-stat-remote-added-total = 3
|
|
@ -0,0 +1,35 @@
|
|||
start = 1258520285, 2009-11-18 12:11:05 +0800
|
||||
end = 1258520290, 2009-11-18 12:11:10 +0800
|
||||
status = 200
|
||||
source-addressbook-mode = slow
|
||||
source-addressbook-first = true
|
||||
source-addressbook-resume = false
|
||||
source-addressbook-status = 0
|
||||
source-addressbook-backup-before = 2
|
||||
source-addressbook-backup-after = 2
|
||||
source-addressbook-stat-local-any-sent = 567
|
||||
source-addressbook-stat-remote-added-total = 2
|
||||
source-calendar-mode = slow
|
||||
source-calendar-first = true
|
||||
source-calendar-resume = false
|
||||
source-calendar-status = 0
|
||||
source-calendar-backup-before = 18
|
||||
source-calendar-backup-after = 18
|
||||
source-calendar-stat-local-any-sent = 9012
|
||||
source-calendar-stat-remote-added-total = 18
|
||||
source-memo-mode = slow
|
||||
source-memo-first = true
|
||||
source-memo-resume = false
|
||||
source-memo-status = 0
|
||||
source-memo-backup-before = 6
|
||||
source-memo-backup-after = 6
|
||||
source-memo-stat-local-any-sent = 154
|
||||
source-memo-stat-remote-added-total = 6
|
||||
source-todo-mode = slow
|
||||
source-todo-first = true
|
||||
source-todo-resume = false
|
||||
source-todo-status = 0
|
||||
source-todo-backup-before = 3
|
||||
source-todo-backup-after = 3
|
||||
source-todo-stat-local-any-sent = 1141
|
||||
source-todo-stat-remote-added-total = 3
|
|
@ -0,0 +1,35 @@
|
|||
start = 1258520367, 2009-11-18 12:11:27 +0800
|
||||
end = 1258520371, 2009-11-18 12:11:31 +0800
|
||||
status = 200
|
||||
source-addressbook-mode = slow
|
||||
source-addressbook-first = true
|
||||
source-addressbook-resume = false
|
||||
source-addressbook-status = 0
|
||||
source-addressbook-backup-before = 2
|
||||
source-addressbook-backup-after = 2
|
||||
source-addressbook-stat-local-any-sent = 567
|
||||
source-addressbook-stat-remote-added-total = 2
|
||||
source-calendar-mode = slow
|
||||
source-calendar-first = true
|
||||
source-calendar-resume = false
|
||||
source-calendar-status = 0
|
||||
source-calendar-backup-before = 18
|
||||
source-calendar-backup-after = 18
|
||||
source-calendar-stat-local-any-sent = 8075
|
||||
source-calendar-stat-remote-added-total = 18
|
||||
source-memo-mode = slow
|
||||
source-memo-first = true
|
||||
source-memo-resume = false
|
||||
source-memo-status = 0
|
||||
source-memo-backup-before = 6
|
||||
source-memo-backup-after = 6
|
||||
source-memo-stat-local-any-sent = 154
|
||||
source-memo-stat-remote-added-total = 6
|
||||
source-todo-mode = slow
|
||||
source-todo-first = true
|
||||
source-todo-resume = false
|
||||
source-todo-status = 0
|
||||
source-todo-backup-before = 3
|
||||
source-todo-backup-after = 3
|
||||
source-todo-stat-local-any-sent = 811
|
||||
source-todo-stat-remote-added-total = 3
|
Loading…
Reference in New Issue