Ejemplo n.º 1
0
    def test_extract_restore_id_basic(self):
        restore_id = uuid.uuid4().hex
        fd, path = tempfile.mkstemp()
        restore_payload = dummy_restore_xml(restore_id).strip()
        with os.fdopen(fd, "wb") as f:
            f.write(restore_payload)

        with open(path, "r") as f:
            extracted, position = extract_synclog_id_from_filelike_payload(f)
            self.assertEqual(restore_id, extracted)
            self.assertEqual(restore_payload.index(restore_id), position)
            # also make sure we reset the file pointer
            self.assertEqual("<OpenRosaResponse", f.read(17))
    def test_extract_restore_id_basic(self):
        restore_id = uuid.uuid4().hex
        fd, path = tempfile.mkstemp()
        restore_payload = dummy_restore_xml(restore_id).strip()
        with os.fdopen(fd, 'wb') as f:
            f.write(restore_payload)

        with open(path, 'r') as f:
            extracted, position = extract_synclog_id_from_filelike_payload(f)
            self.assertEqual(restore_id, extracted)
            self.assertEqual(restore_payload.index(restore_id), position)
            # also make sure we reset the file pointer
            self.assertEqual('<OpenRosaResponse', f.read(17))
Ejemplo n.º 3
0
 def test_extract_restore_id_not_found(self):
     f = StringIO("not much here")
     with self.assertRaises(SyncLogCachingError):
         extract_synclog_id_from_filelike_payload(f)
 def test_extract_restore_id_not_found(self):
     f = StringIO('not much here')
     with self.assertRaises(SyncLogCachingError):
         extract_synclog_id_from_filelike_payload(f)