def isMakeDirsCommand(self, line): assert line is not None parser = MakeDirsParser() isValid = parser.isValidLine(line) return isValid
def getCommandFor(self, line): assert line is not None parser = MakeDirsParser() path = parser.parseLine(line) command = MakeDirsCommand(path) return command
class TestMakeDirsParser(unittest.TestCase): def setUp(self): self.parser = MakeDirsParser() def test_isValid(self): line = 'create dirs bla bla' isValid = self.parser.isValidLine(line) self.assertEqual(True, isValid) def test_isNotValid(self): line = 'create dirs bla bla' isValid = self.parser.isValidLine(line) self.assertEqual(False, isValid) def test_parse(self): line = r"create dirs '~/Some dir/../'" path = self.parser.parseLine(line) self.assertEqual('~/Some dir/../', path)
def setUp(self): self.parser = MakeDirsParser()