36
36
def test_analyze_element_and_record_and_break_relationship(self):
37
37
""" Test for the _analyze_element, analyze_remote_id, analyze_local_id,
38
38
record_relationship, break_relationship """
39
#adding a new local task
39
# adding a new local task
40
has_local_task = self.ftp_local.has_task
41
has_remote_task = self.ftp_remote.has_task
40
42
local_id = uuid.uuid4()
41
43
self.ftp_local.fake_add_task(local_id)
42
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
43
self.ftp_local.has_task, self.ftp_remote.has_task), \
44
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
44
47
(SyncEngine.ADD, None))
45
#creating the related remote task
48
# creating the related remote task
46
49
remote_id = uuid.uuid4()
47
50
self.ftp_remote.fake_add_task(remote_id)
48
#informing the sync_engine about that
51
# informing the sync_engine about that
49
52
self.sync_engine.record_relationship(local_id, remote_id, object())
50
#verifying that it understood that
51
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
52
self.ftp_local.has_task, self.ftp_remote.has_task), \
53
# verifying that it understood that
54
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
53
57
(SyncEngine.UPDATE, remote_id))
54
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
55
self.ftp_local.has_task, self.ftp_remote.has_task), \
58
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,
56
61
(SyncEngine.UPDATE, local_id))
58
self.assertEqual(self.sync_engine.analyze_remote_id(local_id, \
59
self.ftp_local.has_task, self.ftp_remote.has_task), \
60
(SyncEngine.ADD, None))
61
self.assertEqual(self.sync_engine.analyze_local_id(remote_id, \
62
self.ftp_local.has_task, self.ftp_remote.has_task), \
63
(SyncEngine.ADD, None))
64
#now we remove the remote task
63
self.assertEqual(self.sync_engine.analyze_remote_id(local_id,
66
(SyncEngine.ADD, None))
67
self.assertEqual(self.sync_engine.analyze_local_id(remote_id,
70
(SyncEngine.ADD, None))
71
# now we remove the remote task
65
72
self.ftp_remote.fake_remove_task(remote_id)
66
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
67
self.ftp_local.has_task, self.ftp_remote.has_task), \
73
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
68
76
(SyncEngine.REMOVE, None))
69
self.sync_engine.break_relationship(local_id = local_id)
70
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
71
self.ftp_local.has_task, self.ftp_remote.has_task), \
77
self.sync_engine.break_relationship(local_id=local_id)
78
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
72
81
(SyncEngine.ADD, None))
73
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
74
self.ftp_local.has_task, self.ftp_remote.has_task), \
82
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,
75
85
(SyncEngine.ADD, None))
76
86
# we add them back and remove giving the remote id as key to find
79
89
self.ftp_remote.fake_add_task(remote_id)
80
90
self.ftp_remote.fake_remove_task(remote_id)
81
91
self.sync_engine.record_relationship(local_id, remote_id, object)
82
self.sync_engine.break_relationship(remote_id = remote_id)
83
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
84
self.ftp_local.has_task, self.ftp_remote.has_task), \
92
self.sync_engine.break_relationship(remote_id=remote_id)
93
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
85
96
(SyncEngine.ADD, None))
86
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
87
self.ftp_local.has_task, self.ftp_remote.has_task), \
97
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,
88
100
(SyncEngine.ADD, None))
90
102
def test_syncability(self):
91
103
""" Test for the _analyze_element, analyze_remote_id, analyze_local_id.
92
104
Checks that the is_syncable parameter is used correctly """
93
#adding a new local task unsyncable
105
# adding a new local task unsyncable
106
has_local_task = self.ftp_local.has_task
107
has_remote_task = self.ftp_remote.has_task
94
108
local_id = uuid.uuid4()
95
109
self.ftp_local.fake_add_task(local_id)
96
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
97
self.ftp_local.has_task, self.ftp_remote.has_task,
110
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
100
#adding a new local task, syncable
115
# adding a new local task, syncable
101
116
local_id = uuid.uuid4()
102
117
self.ftp_local.fake_add_task(local_id)
103
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
104
self.ftp_local.has_task, self.ftp_remote.has_task), \
118
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
105
121
(SyncEngine.ADD, None))
106
#creating the related remote task
122
# creating the related remote task
107
123
remote_id = uuid.uuid4()
108
124
self.ftp_remote.fake_add_task(remote_id)
109
#informing the sync_engine about that
125
# informing the sync_engine about that
110
126
self.sync_engine.record_relationship(local_id, remote_id, object())
111
#checking that it behaves correctly with established relationships
112
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
113
self.ftp_local.has_task, self.ftp_remote.has_task,
127
# checking that it behaves correctly with established relationships
128
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
115
132
(SyncEngine.UPDATE, remote_id))
116
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
117
self.ftp_local.has_task, self.ftp_remote.has_task,
133
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
119
137
(SyncEngine.LOST_SYNCABILITY, remote_id))
120
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
121
self.ftp_local.has_task, self.ftp_remote.has_task,
138
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,
123
142
(SyncEngine.UPDATE, local_id))
124
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
125
self.ftp_local.has_task, self.ftp_remote.has_task,
143
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,
127
147
(SyncEngine.LOST_SYNCABILITY, local_id))
128
#now we remove the remote task
148
# now we remove the remote task
129
149
self.ftp_remote.fake_remove_task(remote_id)
130
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
131
self.ftp_local.has_task, self.ftp_remote.has_task,
133
(SyncEngine.REMOVE, None))
134
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
135
self.ftp_local.has_task, self.ftp_remote.has_task,
137
(SyncEngine.REMOVE, None))
138
self.sync_engine.break_relationship(local_id = local_id)
139
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
140
self.ftp_local.has_task, self.ftp_remote.has_task,
150
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
154
(SyncEngine.REMOVE, None))
155
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
159
(SyncEngine.REMOVE, None))
160
self.sync_engine.break_relationship(local_id=local_id)
161
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
142
165
(SyncEngine.ADD, None))
143
self.assertEqual(self.sync_engine.analyze_local_id(local_id, \
144
self.ftp_local.has_task, self.ftp_remote.has_task,
166
self.assertEqual(self.sync_engine.analyze_local_id(local_id,
147
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
148
self.ftp_local.has_task, self.ftp_remote.has_task,
171
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,
150
175
(SyncEngine.ADD, None))
151
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id, \
152
self.ftp_local.has_task, self.ftp_remote.has_task,
176
self.assertEqual(self.sync_engine.analyze_remote_id(remote_id,