Ejemplo n.º 1
0
    def test_main_suite_runs_for_multiple_suite(self, mockOpen, mockYamlLoad):
        mockYamlLoad.return_value = {
            'suites': {
                'test': {
                    'report': 'test.txt',
                    'constraints': [{
                        'type': 'bob'
                    }]
                },
                'otherTest': {
                    'report': 'yay.txt',
                    'constraints': [{
                        'type': 'other'
                    }]
                },
                'lastTest': {
                    'report': 'last.txt',
                    'constraints': [{
                        'type': 'last'
                    }]
                }
            }
        }
        self.suite.QualitySuite.available_suites.return_value = [
            'test', 'otherTest', 'lastTest'
        ]
        mockFileContents = {
            'test.txt': 'testTxt',
            'yay.txt': 'otherTxt',
            'last.txt': 'lastTxt'
        }

        def mockFileOpen(filename, *_):
            openMock = mock.MagicMock()
            openMock.__enter__.return_value = StringIO(
                mockFileContents[filename])
            return openMock

        mockOpen.side_effect = mockFileOpen
        main('file')
        self.assertEqual(
            self.suite.QualitySuite.get_suite.return_value.run.call_count, 3)
        self.suite.QualitySuite.get_suite.return_value.run.assert_any_call(
            [{
                'type': 'bob'
            }], 'testTxt')
        self.suite.QualitySuite.get_suite.return_value.run.assert_any_call(
            [{
                'type': 'other'
            }], 'otherTxt')
        self.suite.QualitySuite.get_suite.return_value.run.assert_any_call(
            [{
                'type': 'last'
            }], 'lastTxt')
Ejemplo n.º 2
0
 def test_main_raises_UnknownSuite_when_not_in_availble_suites(
         self, mockOpen, mockYamlLoad):
     mockYamlLoad.return_value = {
         'suites': {
             'test': {
                 'report': 'test.txt',
                 'constraints': [{
                     'type': 'bob'
                 }]
             }
         }
     }
     self.suite.available_suites.return_value = ['otherNonTest']
     with self.assertRaises(UnknownSuite):
         main('file')
Ejemplo n.º 3
0
 def test_main_raises_ReportParsingError_on_IOError(self, mockOpen,
                                                    mockYamlLoad):
     mockYamlLoad.return_value = {
         'suites': {
             'test': {
                 'report': 'test.txt',
                 'constraints': [{
                     'type': 'bob'
                 }]
             }
         }
     }
     self.suite.QualitySuite.available_suites.return_value = ['test']
     self.suite.QualitySuite.get_suite.return_value = {}
     mockOpen.side_effect = IOError('boom')
     with self.assertRaises(ReportParsingError):
         main('file')
Ejemplo n.º 4
0
 def test_main_suite_runs_for_1_suite(self, mockOpen, mockYamlLoad):
     mockYamlLoad.return_value = {
         'suites': {
             'test': {
                 'report': 'test.txt',
                 'constraints': [{
                     'type': 'bob'
                 }]
             }
         }
     }
     self.suite.QualitySuite.available_suites.return_value = ['test']
     mockOpen.return_value.__enter__.return_value = StringIO('reportTxt')
     main('file')
     self.suite.QualitySuite.get_suite.return_value.run.assert_called_once_with(
         [{
             'type': 'bob'
         }], 'reportTxt')
Ejemplo n.º 5
0
 def test_main_raises_ConfigurationParsingError_on_load_Invalid(
         self, mockOpen, mockYamlLoad):
     mockYamlLoad.side_effect = Invalid('boom')
     with self.assertRaises(ConfigurationParsingError):
         main('file')