示例#1
0
 def test_parse_multiline_notetype_command(self, read):
     read.return_value = '''create verb note type and:
                                add fields Russian, Audio, English;
                                add card types e>r, r>e, setting default deck to verbs'''
     with Parser(None, DataSource()) as parser:
         self.assertEqual(parser._commands, [
             'create verb note type and add fields Russian, Audio, English; add card types e>r, r>e, setting default deck to verbs'
         ])
示例#2
0
    def test_parse_multiline_command(self, get_alias, set_note, add_fields,
                                     add_templates, create):
        cmd = '''create ZZZ note type and:
                     add fields "one", two; 
                     add card types e>r, r>e, setting default deck to grammar'''

        datasource._read.return_value = cmd
        get_alias.side_effect = {'ZZZ': 'ZZZ', 'grammar': 'grammar'}.get

        with Parser(course, datasource) as parser:
            for cmd in parser:
                parser._parse(cmd, course=course, datasource=datasource)

        set_note.assert_called_with(create, 'ZZZ', False)
        add_fields.assert_called_with(['one', 'two'])
        add_templates.assert_called_with(['e>r', 'r>e'], 'grammar')
示例#3
0
 def _parse(self, cmd):
     parser = Parser(course, datasource)
     parser._parse(cmd, course=course, datasource=datasource)
示例#4
0
 def test_parse_empty_line(self, read):
     read.return_value = ''
     with Parser(None, DataSource()) as parser:
         self.assertEqual(parser._commands, [''])
示例#5
0
 def test_parse_multiline_command_using_colon(self, read):
     read.return_value = '''for verbs set fields:
                                A=fred, B=bill'''
     with Parser(None, DataSource()) as parser:
         self.assertEqual(parser._commands,
                          ['for verbs set fields A=fred, B=bill'])
示例#6
0
 def test_parse_single_line_command(self, read):
     read.return_value = 'fred was here'
     with Parser(None, DataSource()) as parser:
         self.assertEqual(parser._commands, ['fred was here'])