def add_test_event(self): event = db.RecordedEvent() event.uid = '123' event.start = 1 event.end = 2 event.set_data('') event.status = db.Status.FINISHED_UPLOADING session = db.get_session() session.add(event) session.commit() return db.RecordedEvent(event)
def setUp(self): ingest.http_request = lambda x, y=False: b'xxx' self.fd, self.dbfile = tempfile.mkstemp() self.cadir = tempfile.mkdtemp() config.config('agent')['database'] = 'sqlite:///' + self.dbfile config.config('capture')['directory'] = self.cadir config.config()['services']['org.opencastproject.ingest'] = [''] config.config()['services']['org.opencastproject.capture.admin'] = [''] # Mock event db.init() event = db.RecordedEvent() event.uid = '123123' event.status = db.Status.FINISHED_RECORDING event.start = utils.timestamp() event.end = event.start + 1 prop = 'org.opencastproject.capture.agent.properties' dcns = 'http://www.opencastproject.org/xsd/1.0/dublincore/' data = [{ 'data': u'äü%sÄÜß' % dcns, 'fmttype': 'application/xml', 'x-apple-filename': 'episode.xml' }, { 'data': u'äü%sÄÜß' % dcns, 'fmttype': 'application/xml', 'x-apple-filename': 'series.xml' }, { 'data': u'event.title=äüÄÜß\n' + u'org.opencastproject.workflow.config.x=123\n' + u'org.opencastproject.workflow.definition=fast', 'fmttype': 'application/text', 'x-apple-filename': prop }] event.set_data({'attach': data}) # Create recording os.mkdir(event.directory()) trackfile = os.path.join(event.directory(), 'test.mp4') open(trackfile, 'wb').close() event.set_tracks([('presenter/source', trackfile)]) session = db.get_session() session.add(event) session.commit() self.event = db.RecordedEvent(event)
def test_event(self): e = db.BaseEvent() e.uid = 'asd' e.start = 123 e.end = 234 e.status = db.Status.UPCOMING assert str(e) == '<Event(start=123, uid="asd")>' e = db.RecordedEvent(e) assert e.name() == 'recording-123-asd' assert e.status_str() == 'upcoming' assert e.serialize()['uid'] == 'asd' assert e.get_tracks() == []
def test_event(self): e = db.BaseEvent() e.uid = 'asd' e.start = 123 e.end = 234 e.status = db.Status.UPCOMING e.set_data({}) self.assertEqual(str(e), '<Event(start=123, uid="asd")>') e = db.RecordedEvent(e) self.assertEqual(e.name(), 'recording-123-asd') self.assertEqual(e.status_str(), 'upcoming') self.assertEqual(e.serialize()['id'], 'asd') self.assertEqual(e.get_tracks(), [])