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' ])
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')
def _parse(self, cmd): parser = Parser(course, datasource) parser._parse(cmd, course=course, datasource=datasource)
def test_parse_empty_line(self, read): read.return_value = '' with Parser(None, DataSource()) as parser: self.assertEqual(parser._commands, [''])
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'])
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'])