Ejemplo n.º 1
0
 def test_file_not_found_exception_path(self):
     """A FileNotFoundException reports the path of the missing file."""
     csv_file = os.path.join(self._testdir, 'file.csv')
     actual = ''
     try:
         read_csv_file(csv_file)
     except FileNotFoundException, err:
         actual = err.parameter
Ejemplo n.º 2
0
 def test_file_not_found_exception_path(self):
     """A FileNotFoundException reports the path of the missing file."""
     csv_file = os.path.join(self._testdir, 'file.csv')
     actual = ''
     try:
         read_csv_file(csv_file)
     except FileNotFoundException, err:
         actual = err.parameter
Ejemplo n.º 3
0
 def test_file_read_exception_path(self):
     """A FileReadException reports the path of the missing file."""
     csv_file = os.path.join(self._testdir, 'file.csv')
     actual = ''
     with open(csv_file, 'wb') as fp:
         fp.write("A,B\n1,2\n".encode('utf-16'))
     try:
         read_csv_file(csv_file)
     except FileReadException, err:
         actual = err.parameter
Ejemplo n.º 4
0
 def test_file_read_exception_path(self):
     """A FileReadException reports the path of the missing file."""
     csv_file = os.path.join(self._testdir, 'file.csv')
     actual = ''
     with open(csv_file, 'wb') as fp:
         fp.write("A,B\n1,2\n".encode('utf-16'))
     try:
         read_csv_file(csv_file)
     except FileReadException, err:
         actual = err.parameter
Ejemplo n.º 5
0
 def test_file_read(self):
     """A csv file with unix style line endings can be read"""
     csv_file = os.path.join(self._testdir, 'file.csv')
     with open(csv_file, 'wb') as fp:
         fp.write("A,B\n1,2\n".encode('utf-8'))
     result = read_csv_file(csv_file)
     self.assertEqual(result, [{'A': u'1', 'B': u'2'}])
Ejemplo n.º 6
0
 def test_missing_data_is_blank(self):
     """Blank values are added to missing data fields."""
     csv_file = os.path.join(self._testdir, 'file.csv')
     with open(csv_file, 'wb') as fp:
         fp.write("A,B,C\n1,2\n".encode('utf-8'))
     result = read_csv_file(csv_file)
     self.assertEqual(result[0]['C'], '')
Ejemplo n.º 7
0
 def test_missing_data_is_blank(self):
     """Blank values are added to missing data fields."""
     csv_file = os.path.join(self._testdir, 'file.csv')
     with open(csv_file, 'wb') as fp:
         fp.write("A,B,C\n1,2\n".encode('utf-8'))
     result = read_csv_file(csv_file)
     self.assertEqual(result[0]['C'], '')
Ejemplo n.º 8
0
 def test_file_read_dos_line_endings(self):
     """A csv file with dos line endings can be read"""
     csv_file = os.path.join(self._testdir, 'file.csv')
     with open(csv_file, 'wb') as fp:
         fp.write("A,B\r\n1,2\r\n".encode('utf-8'))
     result = read_csv_file(csv_file)
     self.assertEqual(result,  [{ 'A': u'1', 'B': u'2'}])
Ejemplo n.º 9
0
    def test_resources_values_quotes(self):
        """Check the resource file values do not contain quotes.

        This test is used to verify that no spaces were added between entries
        and the commas separating them (in case the file was edited manually),
        otherwise the string contains the quotes used to delimit it.
        """
        for file in self.files:
            for entry in read_csv_file(file):
                self.assertTrue('"' not in ','.join(entry.values()))
Ejemplo n.º 10
0
    def test_resources_values_quotes(self):
        """Check the resource file values do not contain quotes.

        This test is used to verify that no spaces were added between entries
        and the commas separating them (in case the file was edited manually),
        otherwise the string contains the quotes used to delimit it.
        """
        for file in self.files:
            for entry in read_csv_file(file):
                self.assertTrue('"' not in ','.join(entry.values()))
Ejemplo n.º 11
0
 def test_load_resources(self):
     """All the resource files can be loaded."""
     for file in self.files:
         table = read_csv_file(file)
         self.assertTrue(table)
Ejemplo n.º 12
0
 def test_load_resources(self):
     """All the resource files can be loaded."""
     for file in self.files:
         table = read_csv_file(file)
         self.assertTrue(table)