Esempio n. 1
0
    def setUp(self):
        self.experiments = [
            "experiment1", "experiment2", "experiment2/subdir", "experiment3"
        ]
        self.worklist = [
            "runsample1_filename", "runsample2_filename", "teststuff1.d",
            "teststuff2.d"
        ]

        self.experiments.sort()

        def cleanup_experiments():
            self.experiments.sort(reverse=True)
            for exp in self.experiments:
                try:
                    os.rmdir(os.path.join(TESTING_REPO, exp))
                except OSError:
                    logger.exception("tearDown rmdir")

        self.addCleanup(cleanup_experiments)

        self.temp_files = []
        istemp = lambda f: "TEMP" in f

        for exp in self.experiments:
            destdir = os.path.join(TESTING_REPO, exp)
            os.makedirs(destdir)
            simulator = Simulator(destdir, temp_files=True)
            self.addCleanup(simulator.cleanup)
            simulator.process_worklist(self.worklist)

            self.temp_files.extend(filter(istemp, simulator._created_files))
            self.temp_files.extend(filter(istemp, simulator._created_dirs))
Esempio n. 2
0
    def setup_client(self, **extra_config):
        """
        Creates a test client, CSV worklist, simulator, and the
        necessary data directories.
        Everything will be cleaned up when the test case is torn down.
        Default test config parameters can be overridden with keyword
        arguments.
        """

        self.worklist = WorkList(get_csv_worklist_from_run(
            self.run, self.user))

        self.simulator = Simulator()
        self.addCleanup(self.simulator.cleanup)

        logfile = tempfile.NamedTemporaryFile(prefix="rsync-", suffix=".log")
        archivedir = tempfile.mkdtemp(prefix="archive-")

        config = MSDSConfig(user=self.user,
                            sitename=self.nc.site_name,
                            stationname=self.nc.station_name,
                            organisation=self.nc.organisation_name,
                            localdir=unicode(self.simulator.destdir),
                            synchub="%s/sync/" % 'http://web:8000',
                            logfile=logfile.name,
                            loglevel=plogging.LoggingLevels.DEBUG,
                            archivesynced=False,
                            archivedfilesdir=archivedir)

        config.update(extra_config)

        test_client = TestClient(config, timeout=120, maximize=True)
        test_client.set_window_title(self.id())
        self.test_client = test_client

        self.addCleanup(self.cleanup_client_files)
        self.addCleanup(test_client.quit)

        return test_client