Отрефакторил тесты по созданию бэкапов
This commit is contained in:
parent
31e938809d
commit
bd26508185
|
|
@ -0,0 +1,18 @@
|
|||
from unittest.case import TestCase
|
||||
|
||||
|
||||
class LineParserTestCaseBase(TestCase):
|
||||
def __init__(self, methodName):
|
||||
TestCase.__init__(self, methodName)
|
||||
|
||||
self.textParser = None
|
||||
|
||||
def isValidText(self, text):
|
||||
isValid = self.textParser.isValidLine(text)
|
||||
|
||||
self.assertEqual(True, isValid)
|
||||
|
||||
def isNotValidText(self, text):
|
||||
isValid = self.textParser.isValidLine(text)
|
||||
|
||||
self.assertEqual(False, isValid)
|
||||
|
|
@ -1,19 +1,15 @@
|
|||
import unittest
|
||||
from Tests.UnitTests.LineParserTestCaseBase import LineParserTestCaseBase
|
||||
from parsers.ParserBackup.CreateBackupParser import CreateBackupParser
|
||||
|
||||
|
||||
class TestCreateBackup(unittest.TestCase):
|
||||
class TestCreateBackup(LineParserTestCaseBase):
|
||||
def setUp(self):
|
||||
self.parser = CreateBackupParser()
|
||||
self.textParser = CreateBackupParser()
|
||||
|
||||
def test_isValid(self):
|
||||
line = "create backup"
|
||||
isValid = self.parser.isValidLine(line)
|
||||
|
||||
self.assertEqual(True, isValid)
|
||||
self.isValidText('create backup')
|
||||
self.isValidText('create backup')
|
||||
|
||||
def test_isNotValid(self):
|
||||
line = "create backup bla bla"
|
||||
isValid = self.parser.isValidLine(line)
|
||||
|
||||
self.assertEqual(False, isValid)
|
||||
self.isNotValidText('create backup ')
|
||||
self.isNotValidText('create backup bla bla')
|
||||
|
|
@ -1,25 +1,15 @@
|
|||
import unittest
|
||||
from Tests.UnitTests.LineParserTestCaseBase import LineParserTestCaseBase
|
||||
from parsers.ParserBackup.DeleteBackupParser import DeleteBackupParser
|
||||
|
||||
|
||||
class TestDeleteBackup(unittest.TestCase):
|
||||
class TestDeleteBackup(LineParserTestCaseBase):
|
||||
def setUp(self):
|
||||
self.parser = DeleteBackupParser()
|
||||
self.textParser = DeleteBackupParser()
|
||||
|
||||
def test_parseCurrentDir(self):
|
||||
line = "delete backup '.'"
|
||||
folderPath = self.parser.parseLine(line)
|
||||
def test_isValid(self):
|
||||
self.isValidText('delete backup')
|
||||
self.isValidText('delete backup')
|
||||
|
||||
self.assertEqual('.', folderPath)
|
||||
|
||||
def test_parseRelativePath(self):
|
||||
line = "delete backup '../Some/Path'"
|
||||
folderPath = self.parser.parseLine(line)
|
||||
|
||||
self.assertEqual('../Some/Path', folderPath)
|
||||
|
||||
def test_parseAbsPath(self):
|
||||
line = "delete backup '/Some/Abs/Path'"
|
||||
folderPath = self.parser.parseLine(line)
|
||||
|
||||
self.assertEqual('/Some/Abs/Path', folderPath)
|
||||
def test_isNotValid(self):
|
||||
self.isNotValidText('delete backup ')
|
||||
self.isNotValidText('delete backup bla bla')
|
||||
|
|
|
|||
|
|
@ -1,25 +1,15 @@
|
|||
import unittest
|
||||
from Tests.UnitTests.LineParserTestCaseBase import LineParserTestCaseBase
|
||||
from parsers.ParserBackup.RestoreBackupParser import RestoreBackupParser
|
||||
|
||||
|
||||
class TestRestoreBackup(unittest.TestCase):
|
||||
class TestRestoreBackup(LineParserTestCaseBase):
|
||||
def setUp(self):
|
||||
self.parser = RestoreBackupParser()
|
||||
self.textParser = RestoreBackupParser()
|
||||
|
||||
def test_parseCurrentDir(self):
|
||||
line = "restore from backup '.'"
|
||||
folderPath = self.parser.parseLine(line)
|
||||
def test_isValid(self):
|
||||
self.isValidText('restore from backup')
|
||||
self.isValidText('restore from backup')
|
||||
|
||||
self.assertEqual('.', folderPath)
|
||||
|
||||
def test_parseRelativePath(self):
|
||||
line = "restore from backup '../Some/Path'"
|
||||
folderPath = self.parser.parseLine(line)
|
||||
|
||||
self.assertEqual('../Some/Path', folderPath)
|
||||
|
||||
def test_parseAbsPath(self):
|
||||
line = "restore from backup '/Some/Abs/Path'"
|
||||
folderPath = self.parser.parseLine(line)
|
||||
|
||||
self.assertEqual('/Some/Abs/Path', folderPath)
|
||||
def test_isNotValid(self):
|
||||
self.isNotValidText('restore from backup ')
|
||||
self.isNotValidText('restore from backup bla bla')
|
||||
Loading…
Reference in New Issue