Ejemplo n.º 1
0
    def test_writes_to_output_file_is_called(self, mock_save, mock_propagate,
                                             mock_read):
        cfg_path = os.path.join(self.tempdir, self.configname)

        exp = run.LocalRunExperiment(cfg_path,
                                     'run',
                                     self.log,
                                     section_name='run')
        matfile = os.path.join(self.tempdir, 'mockmat.mat')

        parameters = [
            '--qindex', '1', '--src', '0', '--dst', '1', '--matfile', matfile,
            '--out', 'test.txt'
        ]
        sys.stdout = StringIO.StringIO()
        sys.stderr = StringIO.StringIO()
        result = exp.run(parameters, self.configname)
        os.remove('run.cfg')
        sys.stderr = sys.__stderr__
        sys.stdout = sys.__stdout__

        mock_read.assert_called_with('.', matfile, memsave=False)
        mock_propagate.assert_called()
        mock_save.assert_called_with('test.txt', [])
        self.assertEqual(result, 0)
Ejemplo n.º 2
0
    def test_required_parameters_missing_returns_without_running(self):
        cfg_path = os.path.join(self.tempdir, self.configname)
        exp = run.LocalRunExperiment(cfg_path,
                                     'run',
                                     self.log,
                                     section_name='run')

        sys.stdout = StringIO.StringIO()
        sys.stderr = StringIO.StringIO()
        result = exp.run([], self.configname)
        os.remove('run.cfg')
        sys.stderr = sys.__stderr__
        sys.stdout = sys.__stdout__

        self.assertEqual(result, -1)
Ejemplo n.º 3
0
    def test_required_parameters_non_existing_file_returns_without_running(
            self):
        cfg_path = os.path.join(self.tempdir, self.configname)
        exp = run.LocalRunExperiment(cfg_path,
                                     'run',
                                     self.log,
                                     section_name='run')

        parameters = [
            '--qindex', '1', '--src', '0', '--dst', '1', '--matfile',
            'test.mat'
        ]
        sys.stdout = StringIO.StringIO()
        sys.stderr = StringIO.StringIO()
        result = exp.run(parameters, self.configname)
        os.remove('run.cfg')
        sys.stderr = sys.__stderr__
        sys.stdout = sys.__stdout__

        self.assertEqual(result, -1)
Ejemplo n.º 4
0
    def test_network_as_wrong_dst_returns_minus_one(self, mock_propagate,
                                                    mock_read):
        cfg_path = os.path.join(self.tempdir, self.configname)

        exp = run.LocalRunExperiment(cfg_path,
                                     'run',
                                     self.log,
                                     section_name='run')
        matfile = os.path.join(self.tempdir, 'mockmat.mat')

        parameters = [
            '--qindex', '1', '--src', '0', '--dst', '-1', '--matfile', matfile,
            '--memsave', 'True'
        ]
        sys.stdout = StringIO.StringIO()
        sys.stderr = StringIO.StringIO()
        result = exp.run(parameters, self.configname)
        os.remove('run.cfg')
        sys.stderr = sys.__stderr__
        sys.stdout = sys.__stdout__

        self.assertEqual(result, -1)
Ejemplo n.º 5
0
    def test_required_parameters_qname_non_existing(self, mock_exit,
                                                    mock_read):
        cfg_path = os.path.join(self.tempdir, self.configname)

        exp = run.LocalRunExperiment(cfg_path,
                                     'run',
                                     self.log,
                                     section_name='run')
        matfile = os.path.join(self.tempdir, 'mockmat.mat')

        parameters = [
            '--qname', '1', '--src', '0', '--dst', '1', '--matfile', matfile
        ]
        sys.stdout = StringIO.StringIO()
        sys.stderr = StringIO.StringIO()
        result = exp.run(parameters, self.configname)
        os.remove('run.cfg')
        sys.stderr = sys.__stderr__
        sys.stdout = sys.__stdout__

        mock_read.assert_called_with('.', matfile, memsave=False)
        mock_exit.assert_called()

        self.assertEqual(result, -1)