Ejemplo n.º 1
0
 def test_empty(self):
     """
     Testing of a empty csv
     """
     with self.assertRaises(ValueError):
         model = PyCSVModel(csvpath='testcsvs/testcsv4.csv')
         model.read_file()
Ejemplo n.º 2
0
 def test_wrong_delimiter(self):
     """
     Testing a csv with wrong delimiter
     """
     with self.assertRaises(ValueError):
         model = PyCSVModel(csvpath='testcsvs/testcsv5.csv')
         model.read_file()
         self.assertEqual([], model.data)
Ejemplo n.º 3
0
 def test_only_title(self):
     """
     Testing of a csv file with only a title
     """
     expecteddict = []
     model = PyCSVModel(csvpath='testcsvs/testcsv3.csv')
     model.read_file()
     self.assertEqual(expecteddict, model.data)
Ejemplo n.º 4
0
 def test_read_csv(self):
     """
     Testing of a successful csv read
     """
     expecteddict = [{'titel': 'TestTitel', 'id': '0', 'content': 'TestContent'}]
     model = PyCSVModel(csvpath='testcsvs/testcsv1.csv')
     model.read_file()
     self.assertEqual(expecteddict, model.data)
Ejemplo n.º 5
0
 def test_tworows(self):
     """
     Testing of a successful csv read with two rows
     """
     expecteddict = [{'titel': 'TestTitel', 'id': '0', 'content': 'TestContent'},
                     {'titel': 'bla', 'id': '1', 'content': 'blub'}]
     model = PyCSVModel(csvpath='testcsvs/testcsv2.csv')
     model.read_file()
     self.assertEqual(expecteddict, model.data)
Ejemplo n.º 6
0
class PyCSVController:
    """
    Class for controlling the program
    """
    def __init__(self, csvpath=None):
        """
        Constructor for initialising the program
        :param csvpath: the path of the csv
        """
        self.pycsvguimodel = PyCSVModel(csvpath=csvpath)
        self.pycsvguimodel.read_file()