def setUp(self):
     """Common initialization."""
     exporter_unit = self._get_all_exporter_units(
     )['2013.com.canonical.plainbox::hexr']
     self.exporter = Jinja2SessionStateExporter(
         system_id='SYSTEM_ID',
         timestamp='TIMESTAMP',
         client_version='CLIENT_VERSION',
         client_name='CLIENT_NAME',
         exporter_unit=exporter_unit)
     self.manager = SessionManager.create()
     self.manager.add_local_device_context()
Beispiel #2
0
 def setUp(self):
     self.exporter_unit = self._get_all_exporter_units()[
         '2013.com.canonical.plainbox::html']
     self.resource_map = {
         '2013.com.canonical.certification::lsb': [
             Resource({'description': 'Ubuntu 14.04 LTS'})],
         '2013.com.canonical.certification::package': [
             Resource({'name': 'plainbox', 'version': '1.0'}),
             Resource({'name': 'fwts', 'version': '0.15.2'})],
     }
     self.job1 = JobDefinition({'id': 'job_id1', '_summary': 'job 1'})
     self.job2 = JobDefinition({'id': 'job_id2', '_summary': 'job 2'})
     self.job3 = JobDefinition({'id': 'job_id3', '_summary': 'job 3'})
     self.result_fail = MemoryJobResult({
         'outcome': IJobResult.OUTCOME_FAIL, 'return_code': 1,
         'io_log': [(0, 'stderr', b'FATAL ERROR\n')],
     })
     self.result_pass = MemoryJobResult({
         'outcome': IJobResult.OUTCOME_PASS, 'return_code': 0,
         'io_log': [(0, 'stdout', b'foo\n')],
         'comments': 'blah blah'
     })
     self.result_skip = MemoryJobResult({
         'outcome': IJobResult.OUTCOME_SKIP,
         'comments': 'No such device'
     })
     self.attachment = JobDefinition({
         'id': 'dmesg_attachment',
         'plugin': 'attachment'})
     self.attachment_result = MemoryJobResult({
         'outcome': IJobResult.OUTCOME_PASS,
         'io_log': [(0, 'stdout', b'bar\n')],
         'return_code': 0
     })
     self.session_manager = SessionManager.create()
     self.session_manager.add_local_device_context()
     self.session_state = self.session_manager.default_device_context.state
     session_state = self.session_state
     session_state.add_unit(self.job1)
     session_state.add_unit(self.job2)
     session_state.add_unit(self.job3)
     session_state.add_unit(self.attachment)
     session_state.update_job_result(self.job1, self.result_fail)
     session_state.update_job_result(self.job2, self.result_pass)
     session_state.update_job_result(self.job3, self.result_skip)
     session_state.update_job_result(
         self.attachment, self.attachment_result)
     for resource_id, resource_list in self.resource_map.items():
         session_state.set_resource_list(resource_id, resource_list)
Beispiel #3
0
 def test_create(self, **mocks):
     """
     verify that SessionManager.create() correctly sets up
     storage repository and creates session directories
     """
     mocks['SessionStorage'].create.return_value = mock.MagicMock(
         spec_set=SessionStorage)
     # Create the new manager
     manager = SessionManager.create()
     # Ensure that a storage was created, with repository location and
     # without legacy mode turned on
     mocks['SessionStorage'].create.assert_called_with('pbox-')
     storage = mocks['SessionStorage'].create()
     # Ensure that the resulting manager has correct data inside
     self.assertEqual(manager.device_context_list, [])
     self.assertEqual(manager.storage, storage)
 def test_create(self, **mocks):
     """
     verify that SessionManager.create() correctly sets up
     storage repository and creates session directories
     """
     mocks['SessionStorage'].create.return_value = mock.MagicMock(
         spec_set=SessionStorage)
     # Create the new manager
     manager = SessionManager.create()
     # Ensure that a default repository was created
     mocks['SessionStorageRepository'].assert_called_with()
     repo = mocks['SessionStorageRepository']()
     # Ensure that a storage was created, with repository location and
     # without legacy mode turned on
     mocks['SessionStorage'].create.assert_called_with(repo.location, False)
     storage = mocks['SessionStorage'].create()
     # Ensure that a default directories were created
     mocks['WellKnownDirsHelper'].assert_called_with(storage)
     helper = mocks['WellKnownDirsHelper']()
     helper.populate.assert_called_with()
     # Ensure that the resulting manager has correct data inside
     self.assertEqual(manager.device_context_list, [])
     self.assertEqual(manager.storage, storage)