def testMainInsideChroot(self):
    """Test flow inside chroot"""
    argv = []
    mocked_insidechroot = self.mox.CreateMock(cgt.InsideChroot)

    # Create replay script.
    self.mox.StubOutWithMock(build_lib, 'IsInsideChroot')
    self.mox.StubOutWithMock(cgt.InsideChroot, '__new__')

    build_lib.IsInsideChroot().AndReturn(True)
    cgt.InsideChroot.__new__(cgt.InsideChroot).AndReturn(mocked_insidechroot)
    mocked_insidechroot.Run()
    self.mox.ReplayAll()

    # Run test verification.
    with self.OutputCapturer():
      cgt.main(argv)
    self.mox.VerifyAll()
    def testMainOutsideChroot(self):
        """Test flow outside chroot"""
        argv = []
        mocked_outsidechroot = self.mox.CreateMock(cgt.OutsideChroot)

        # Create replay script.
        self.mox.StubOutWithMock(build_lib, "IsInsideChroot")
        self.mox.StubOutWithMock(cgt.OutsideChroot, "__new__")

        build_lib.IsInsideChroot().AndReturn(False)
        cgt.OutsideChroot.__new__(cgt.OutsideChroot, argv).AndReturn(mocked_outsidechroot)
        mocked_outsidechroot.Run()
        self.mox.ReplayAll()

        # Run test verification.
        with self.OutputCapturer():
            cgt.main(argv)
        self.mox.VerifyAll()
    def testMainInsideChroot(self):
        """Test flow inside chroot"""
        argv = []
        mocked_insidechroot = self.mox.CreateMock(cgt.InsideChroot)

        # Create replay script.
        self.mox.StubOutWithMock(build_lib, 'IsInsideChroot')
        self.mox.StubOutWithMock(cgt.InsideChroot, '__new__')

        build_lib.IsInsideChroot().AndReturn(True)
        cgt.InsideChroot.__new__(
            cgt.InsideChroot).AndReturn(mocked_insidechroot)
        mocked_insidechroot.Run()
        self.mox.ReplayAll()

        # Run test verification.
        with self.OutputCapturer():
            cgt.main(argv)
        self.mox.VerifyAll()