2 # This file is part of my.gpodder.org.
4 # my.gpodder.org is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version.
9 # my.gpodder.org is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
12 # License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
21 from django
.test
import TestCase
24 from mygpo
.users
.models
import User
, Device
27 class DeviceSyncTests(unittest
.TestCase
):
30 self
.user
= User(username
='test')
31 self
.user
.email
= 'test@invalid.com'
32 self
.user
.set_password('secret!')
37 dev1
= Device(uid
='d1')
38 self
.user
.devices
.append(dev1
)
40 dev2
= Device(uid
='d2')
41 self
.user
.devices
.append(dev2
)
43 group
= self
.user
.get_grouped_devices().next()
44 self
.assertEquals(group
.is_synced
, False)
45 self
.assertIn(dev1
, group
.devices
)
46 self
.assertIn(dev2
, group
.devices
)
49 dev3
= Device(uid
='d3')
50 self
.user
.devices
.append(dev3
)
52 self
.user
.sync_devices(dev1
, dev3
)
54 groups
= self
.user
.get_grouped_devices()
57 self
.assertEquals(g1
.is_synced
, True)
58 self
.assertIn(dev1
, g1
.devices
)
59 self
.assertIn(dev3
, g1
.devices
)
62 self
.assertEquals(g2
.is_synced
, False)
63 self
.assertIn(dev2
, g2
.devices
)
66 targets
= self
.user
.get_sync_targets(dev1
)
67 target
= targets
.next()
68 self
.assertEquals(target
, dev2
)
72 suite
= unittest
.TestSuite()
73 suite
.addTest(unittest
.TestLoader().loadTestsFromTestCase(DeviceSyncTests
))