~ubuntu-core-dev/update-manager/main

« back to all changes in this revision

Viewing changes to tests/test_aptsources.py

  • Committer: glatzor at ubuntu
  • Date: 2006-09-11 08:51:15 UTC
  • mfrom: (358.1.49 main)
  • mto: (337.5.12 separation)
  • mto: This revision was merged to the branch mainline in revision 366.
  • Revision ID: glatzor@ubuntu.com-20060911085115-439dbbad72cf1a2d
* merge with mvo

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
        sources = aptsources.SourcesList()
82
82
        distro = aptsources.Distribution()
83
83
        distro.get_sources(sources)
 
84
        # test if all suits of the current distro were detected correctly
 
85
        dist_templates = set()
 
86
        for s in sources:
 
87
            if s.template:
 
88
                dist_templates.add(s.template.name)
 
89
        #print dist_templates
 
90
        for d in ["edgy","edgy-security","edgy-updates","hoary","breezy", "breezy-backports"]:
 
91
            self.assertTrue(d in dist_templates)
 
92
        # test enable 
84
93
        comp = "restricted"
85
94
        distro.enable_component(sources, comp)
86
 
        found = 0
 
95
        found = {}
87
96
        for entry in sources:
88
97
            if (entry.type == "deb" and
89
98
                entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
90
 
                entry.dist == "edgy"):
91
 
                for c in entry.comps:
92
 
                    if c == comp:
93
 
                        found += 1
94
 
        print "".join([s.str() for s in sources])
95
 
        self.assertEqual(found, 1)
96
 
        
 
99
                "edgy" in entry.dist):
 
100
                for c in entry.comps:
 
101
                    if c == comp:
 
102
                        if not found.has_key(entry.dist):
 
103
                            found[entry.dist] = 0
 
104
                        found[entry.dist] += 1
 
105
        #print "".join([s.str() for s in sources])
 
106
        for key in found:
 
107
            self.assertEqual(found[key], 1)
 
108
 
 
109
        # add a not-already available component
 
110
        comp = "multiverse"
 
111
        distro.enable_component(sources, comp)
 
112
        found = {}
 
113
        for entry in sources:
 
114
            if (entry.type == "deb" and
 
115
                entry.template and
 
116
                entry.template.name == "edgy"):
 
117
                for c in entry.comps:
 
118
                    if c == comp:
 
119
                        if not found.has_key(entry.dist):
 
120
                            found[entry.dist] = 0
 
121
                        found[entry.dist] += 1
 
122
        #print "".join([s.str() for s in sources])
 
123
        for key in found:
 
124
            self.assertEqual(found[key], 1)
97
125
 
98
126
if __name__ == "__main__":
99
127
    unittest.main()