Beispiel #1
0
    def testParseFull(self):
        xml_file = project_file('test/sample/CompletedTranscript.xml')
        script = Transcript.from_xml_file(xml_file)

        self.assertEquals('42', script.script_identifier)
        self.assertEquals('testTagger', script.tagger)
        self.assertEquals('testVerifier', script.verifier)
        self.assertEquals(
            '2013-11-17T20:43:04.683-05:00',
            script.begin_datetime
        )
        self.assertEquals(150.28, script.script_duration)
        self.assertEquals(0.08, script.learner_lag_duration)
        self.assertEquals('MAT/116', script.class_level)
        self.assertEquals('Live Math Tutoring - MAT/116', script.domain)
        self.assertEquals('Linear Equations', script.area)
        self.assertEquals('Solving Linear Equations', script.subarea)
        self.assertEquals(
            'confused on the gallons',
            script.problem_from_learner
        )
        self.assertEquals('This tutor is great', script.learner_notes)
        self.assertEquals('This student is great', script.tutor_notes)

        utt = script.utterance_list[1]
        self.assertEquals('00:00:00', utt['timestamp'])
        self.assertEquals('KIMBERLY (Customer)', utt['speaker'])
        self.assertEquals('confused on the gallons', utt['text'])

        utt = script.utterance_list[-1]
        self.assertEquals('02:30:13', utt['timestamp'])
        self.assertEquals('You', utt['speaker'])
        self.assertEquals('bye', utt['text'])
Beispiel #2
0
def before_first():
    app_logger().info('Handling database init')

    if application.debug:
        # Debug/local dev
        default_database(Database('sqlite', filename=project_file('.test.db')))
    else:
        # Production!
        default_database(Database('dynamodb'))

    # Make sure we have our tables
    User.ensure_table()
    Transcript.ensure_table()
    Taxonomy.ensure_table()

    # Some debug data we might find useful
    if application.debug:
        TEST_EMAIL = application.config.get('TEST_EMAIL')
        me = first(User.find_by_index('idx_email', TEST_EMAIL))
        if not me:
            me = User(name='Test User', email=TEST_EMAIL)
            me.save()

        if not Transcript.find_all():
            ts1 = Transcript.from_xml_file(
                project_file('test/sample/SampleTranscript.xml')
            )
            ts1.script_identifier = 'Original Owned'
            ts1.owner = me.id
            ts1.tagger = ''
            ts1.id = ''
            ts1.save()

            ts2 = Transcript.from_xml_file(
                project_file('test/sample/SampleTranscript.xml')
            )
            ts2.script_identifier = 'New Assigned'
            ts2.owner = me.id
            ts2.tagger = me.id
            ts2.source_transcript = ts1.id
            ts2.id = ''  # Ensure new id on save
            ts2.save()