Beispiel #1
0
 def test_app_id_assignment(self):
     metadata = SessionMetaData()
     metadata.app_id = 'com.canonical.certification.plainbox'
     self.assertEqual(
         metadata.app_id, 'com.canonical.certification.plainbox')
     metadata.app_id = None
     self.assertEqual(metadata.app_id, None)
Beispiel #2
0
 def test_app_id_assignment(self):
     metadata = SessionMetaData()
     metadata.app_id = 'com.canonical.certification.plainbox'
     self.assertEqual(metadata.app_id,
                      'com.canonical.certification.plainbox')
     metadata.app_id = None
     self.assertEqual(metadata.app_id, None)
Beispiel #3
0
 def test_accessors(self):
     metadata = SessionMetaData()
     metadata.title = "title"
     self.assertEqual(metadata.title, "title")
     metadata.flags = set(["f1", "f2"])
     self.assertEqual(metadata.flags, set(["f1", "f2"]))
     metadata.running_job_name = "id"
     self.assertEqual(metadata.running_job_name, "id")
Beispiel #4
0
 def test_accessors(self):
     metadata = SessionMetaData()
     metadata.title = "title"
     self.assertEqual(metadata.title, "title")
     metadata.flags = set(["f1", "f2"])
     self.assertEqual(metadata.flags, set(["f1", "f2"]))
     metadata.running_job_name = "name"
     self.assertEqual(metadata.running_job_name, "name")
Beispiel #5
0
 def test_initializer(self):
     metadata = SessionMetaData(title="title",
                                flags=['f1', 'f2'],
                                running_job_name='id')
     self.assertEqual(metadata.title, "title")
     self.assertEqual(metadata.flags, set(["f1", "f2"]))
     self.assertEqual(metadata.running_job_name, "id")
Beispiel #6
0
 def test_repr_SessionMetaData_empty_metadata(self):
     """
     verify that representation of empty SessionMetaData is okay
     """
     # all defaults with empty values
     data = self.helper._repr_SessionMetaData(SessionMetaData())
     self.assertEqual(data, {
         'title': None,
         'flags': [],
         'running_job_name': None
     })
    def _build_SessionState(self, session_repr, early_cb=None):
        """
        Reconstruct the session state object.

        This method creates a fresh SessionState instance and restores
        jobs, results, meta-data and desired job list using helper methods.
        """
        logger.debug(_("Starting to restore metadata..."))
        metadata = SessionMetaData()
        self._peek_SessionState_metadata(metadata, session_repr)
        return metadata
Beispiel #8
0
 def prepare_manager_single_job(self):
     result = mock.Mock(spec_set=MemoryJobResult,
                        outcome='fail',
                        is_hollow=False)
     result.tr_outcome.return_value = 'fail'
     job = mock.Mock(spec_set=JobDefinition, id='job_id')
     job.tr_summary.return_value = 'job name'
     self.manager_single_job = mock.Mock(state=mock.Mock(
         metadata=SessionMetaData(),
         run_list=[job],
         job_state_map={job.id: mock.Mock(result=result, job=job)}))
    def peek_json(self, json_repr):
        """
        Resume a SessionState object from the JSON representation.

        This method is called by :meth:`peek()` after the initial envelope and
        parsing is done. The only error conditions that can happen are related
        to semantic incompatibilities or corrupted internal state.
        """
        _validate(json_repr, key="version", choice=[1])
        session_repr = _validate(json_repr, key='session', value_type=dict)
        metadata = SessionMetaData()
        self._restore_SessionState_metadata(metadata, session_repr)
        return metadata
Beispiel #10
0
 def test_repr_SessionMetaData_typical_metadata(self):
     """
     verify that representation of typical SessionMetaData is okay
     """
     # no surprises here, just the same data copied over
     data = self.helper._repr_SessionMetaData(
         SessionMetaData(title='USB Testing session',
                         flags=['incomplete'],
                         running_job_name='usb/detect'), self.session_dir)
     self.assertEqual(
         data, {
             'title': 'USB Testing session',
             'flags': ['incomplete'],
             'running_job_name': 'usb/detect',
         })
Beispiel #11
0
 def test_repr_SessionMetaData_empty_metadata(self):
     """
     verify that representation of empty SessionMetaData is okay
     """
     # all defaults with empty values
     data = self.helper._repr_SessionMetaData(SessionMetaData(),
                                              self.session_dir)
     print(data)
     self.assertEqual(
         data, {
             'title': None,
             'flags': [],
             'running_job_name': None,
             'app_blob': '',
             'app_id': None,
             'custom_joblist': False,
             'rejected_jobs': []
         })
Beispiel #12
0
 def test_repr_SessionMetaData_typical_metadata(self):
     """
     verify that representation of typical SessionMetaData is okay
     """
     # no surprises here, just the same data copied over
     data = self.helper._repr_SessionMetaData(
         SessionMetaData(
             title='USB Testing session',
             flags=['incomplete'],
             running_job_name='usb/detect',
             app_blob=b'blob',
             app_id='com.canonical.certification.plainbox',
         ), self.session_dir)
     self.assertEqual(
         data, {
             'title': 'USB Testing session',
             'flags': ['incomplete'],
             'running_job_name': 'usb/detect',
             'app_blob': 'YmxvYg==',
             'app_id': 'com.canonical.certification.plainbox'
         })
Beispiel #13
0
 def test_app_id_kwarg_to_init(self):
     metadata = SessionMetaData(
         app_id='com.canonical.certification.plainbox')
     self.assertEqual(metadata.app_id,
                      'com.canonical.certification.plainbox')
Beispiel #14
0
 def test_app_blob_default_value(self):
     metadata = SessionMetaData()
     self.assertIs(metadata.app_blob, b'')
Beispiel #15
0
 def test_app_blob_assignment(self):
     metadata = SessionMetaData()
     metadata.app_blob = b'blob'
     self.assertEqual(metadata.app_blob, b'blob')
     metadata.app_blob = None
     self.assertEqual(metadata.app_blob, None)
Beispiel #16
0
 def test_app_id_default_value(self):
     metadata = SessionMetaData()
     self.assertIs(metadata.app_id, None)
Beispiel #17
0
 def test_app_blob_kwarg_to_init(self):
     metadata = SessionMetaData(app_blob=b'blob')
     self.assertEqual(metadata.app_blob, b'blob')
Beispiel #18
0
 def test_app_blob_assignment(self):
     metadata = SessionMetaData()
     metadata.app_blob = b'blob'
     self.assertEqual(metadata.app_blob, b'blob')
     metadata.app_blob = None
     self.assertEqual(metadata.app_blob, None)
Beispiel #19
0
 def test_smoke(self):
     metadata = SessionMetaData()
     self.assertEqual(metadata.title, None)
     self.assertEqual(metadata.flags, set())
     self.assertEqual(metadata.running_job_name, None)