3 # Author: Martin Matusiak <numerodix@gmail.com>
4 # Licensed under the GNU Public License, version 3.
11 from sdict
import sdict
, sdictlist
14 class TestSdictList(unittest
.TestCase
):
17 self
.network1
= sdict()
18 self
.network1
.essid
= "linksys"
19 self
.network1
.bssid
= "11:22:33:44:55:66"
20 self
.network1
.priority
= 75
22 self
.network2
= sdict()
23 self
.network2
.essid
= "NETGEAR"
25 self
.network3
= sdict()
26 self
.network3
.essid
= "Cisco"
27 self
.network3
.priority
= 60
29 self
.lst
= sdictlist(sort_key
="priority")
30 self
.lst
.append(self
.network1
)
31 self
.lst
.append(self
.network2
)
32 self
.lst
.append(self
.network3
)
35 dl
= sdictlist(init_list
=[self
.network1
, self
.network2
])
36 self
.assert_(len(dl
) == 2)
38 def test_ordering(self
):
39 self
.assert_(self
.lst
.get_top().essid
== "linksys")
42 s
= self
.lst
.sort(sort_key
="bssid")
43 self
.assert_(s
.get_top().essid
== "linksys")
47 network4
.essid
= "Sitecom"
50 network5
.essid
= "Cisco"
51 network5
.priority
= 90
53 dl
= sdictlist(init_list
=[network4
, network5
])
54 dl
= self
.lst
.merge(dl
, "essid")
56 self
.assert_(len(dl
) == 4)
57 self
.assert_(dl
.get_top().essid
== "Cisco")
61 suite
= unittest
.makeSuite(TestSdictList
)
62 unittest
.TextTestRunner(verbosity
=verbosity
).run(suite
)
64 if __name__
== "__main__":