def structs():
            """Mockups for called scripts."""
            server = MockUCSHttpServer('server')
            struct_r = U.UCSRepoPool(major=MAJOR,
                                     minor=MINOR,
                                     part=PART,
                                     patchlevel=PATCH,
                                     arch=ARCH)
            preup_r = struct_r.path('preup.sh')
            postup_r = struct_r.path('postup.sh')
            struct_c = U.UCSRepoPool(major=MAJOR,
                                     minor=MINOR,
                                     part='%s/component' % (PART, ),
                                     patch='c',
                                     arch=ARCH)
            preup_c = struct_c.path('preup.sh')
            postup_c = struct_c.path('postup.sh')

            yield (server, struct_r, 'preup', preup_r, 'r_pre')
            yield (server, struct_r, 'postup', postup_r, 'r_post')
            yield (server, struct_c, 'preup', preup_c, 'c_pre')
            yield (server, struct_c, 'postup', postup_c, 'c_post')
 def test__iterate_release(self):
     """Test iterating releases."""
     start = U.UCS_Version((3, 0, 0))
     end = U.UCS_Version((4, 4, 1))
     ver = U.UCSRepoPool()
     it = self.u._iterate_release(ver, start, end)
     self.assertEqual(next(it).mmp, (3, 0, 0))
     self.assertEqual(it.send(True).mmp, (4, 0, 0))
     self.assertEqual(it.send(True).mmp, (4, 1, 0))
     self.assertEqual(it.send(True).mmp, (4, 2, 0))
     self.assertEqual(it.send(True).mmp, (4, 3, 0))
     self.assertEqual(it.send(False).mmp, (4, 3, 1))
     self.assertEqual(it.send(True).mmp, (4, 4, 0))
     self.assertEqual(it.send(False).mmp, (4, 4, 1))
     with self.assertRaises(StopIteration):
         self.assertEqual(it.next(), (4, 4, 1))
    def test_get_sh_files(self):
        """Test preup.sh / postup.sh download."""
        server = MockUCSHttpServer('server')
        struct = U.UCSRepoPool(major=MAJOR,
                               minor=MINOR,
                               part=PART,
                               patchlevel=PATCH,
                               arch=ARCH)
        preup_path = struct.path('preup.sh')
        server.mock_add(preup_path, '#!preup_content')
        postup_path = struct.path('postup.sh')
        server.mock_add(postup_path, '#!postup_content')
        repo = ((server, struct), )

        gen = U.UniventionUpdater.get_sh_files(repo)

        self.assertEqual(
            (server, struct, 'preup', preup_path, '#!preup_content'),
            gen.next())
        self.assertEqual(
            (server, struct, 'postup', postup_path, '#!postup_content'),
            gen.next())
        self.assertRaises(StopIteration, gen.next)