Ejemplo n.º 1
0
class FileReaderTestCase(unittest.TestCase):
    def setUp(self):
        """
        manitest file location: ../manifests/opencart.txt
        with following contents
        -----------------------------------
        basepath=/home/vineet/public_html/
        basedir=opencart_v1.4.9.4

        index.php
        catalog/controller/account/account.php
        catalog/controller/account/create.php
        catalog/controller/feed/*
        catalog/model/**
        -----------------------------------
        """
        self.file = '../manifests/opencart.txt'
        self.reader = FileReader(self.file)

    def test_reader_type(self):
        self.assertEqual(FileReader.reader_type, 'file')

    def test_init(self):
        self.assertEqual(self.reader.file, self.file)

    def test_get_property(self):
        """
        This is just a static method.
        so just providing the input params
        """
        line = 'basepath=/home/vineet/public_html/'
        self.assertEqual(FileReader.get_property(line),
                         '/home/vineet/public_html/')

    def test_get_lines(self):
        lines = self.reader.get_lines()
        self.assertEqual(len(lines), 8 + 1)
        self.assertEqual(lines[2], '')
        self.assertEqual(lines[3], 'index.php')
        self.assertEqual(lines[7], 'catalog/model/**')

    def test_get_config(self):
        config = self.reader.get_config()
        self.assertEqual(config['source_base_path'],
                         '/home/vineet/public_html/')
        self.assertEqual(config['source_dir'], 'opencart_v1.4.9.4')
        self.assertEqual(config['source_path'],
                         '/home/vineet/public_html/opencart_v1.4.9.4/')
        self.assertEqual(config['target_dir'], '../target/opencart_v1.4.9.4/')
        self.assertEqual(len(config['lines']), 8 + 1 - 2)
Ejemplo n.º 2
0
class FileReaderTestCase(unittest.TestCase):
    def setUp(self):
        """
        manitest file location: ../manifests/opencart.txt
        with following contents
        -----------------------------------
        basepath=/home/vineet/public_html/
        basedir=opencart_v1.4.9.4

        index.php
        catalog/controller/account/account.php
        catalog/controller/account/create.php
        catalog/controller/feed/*
        catalog/model/**
        -----------------------------------
        """
        self.file = '../manifests/opencart.txt'
        self.reader = FileReader(self.file)

    def test_reader_type(self):
        self.assertEqual(FileReader.reader_type, 'file')

    def test_init(self):
        self.assertEqual(self.reader.file, self.file)

    def test_get_property(self):
        """
        This is just a static method.
        so just providing the input params
        """
        line = 'basepath=/home/vineet/public_html/'
        self.assertEqual(FileReader.get_property(line), '/home/vineet/public_html/')

    def test_get_lines(self):
        lines = self.reader.get_lines()
        self.assertEqual(len(lines), 8+1)
        self.assertEqual(lines[2], '')
        self.assertEqual(lines[3], 'index.php')
        self.assertEqual(lines[7], 'catalog/model/**')

    def test_get_config(self):
        config = self.reader.get_config()
        self.assertEqual(config['source_base_path'], '/home/vineet/public_html/')
        self.assertEqual(config['source_dir'], 'opencart_v1.4.9.4')
        self.assertEqual(config['source_path'], '/home/vineet/public_html/opencart_v1.4.9.4/')
        self.assertEqual(config['target_dir'], '../target/opencart_v1.4.9.4/')
        self.assertEqual(len(config['lines']), 8+1-2)