Пример #1
0
 def save_membership_data_to_csv(self, file_name, membership):
     """ Method to save membership data to CSV file
     
     Arguments:
     
     file_name -- file where will be saved the membership
     membership -- membership objtect that will be saved in the CSV file
     
     """
     row = [str(membership.get_code()), membership.get_name(), str(membership.get_discount())]
     list_membership = []
     list_membership.append(row)
     CsvOperations.write_data(file_name, list_membership)
Пример #2
0
 def read_membership_data_from_csv(self, file_name):
     """ Method to read membership data to CSV file
     
     Arguments:
     file_name -- file that will be readed to obtain the memberships
     
     Returned value:
     membership -- the first row of the returned list from CSV.read method
     
     """
     membership = CsvOperations.read_data(file_name)
     return membership[0]
Пример #3
0
 def test_write_data_in_csv(self):
     """ Test that all data are wrote in the csv file"""
     expected = [["uno", "dos", "tres"], ["cuatro", "cinco", "seis"]]
     CsvOperations.write_data("test.csv", expected)
     self.assertEqual(CsvOperations.read_data("test.csv"), expected)
Пример #4
0
 def test_read_data_from_csv(self):
     """ test that all data are being read from csv file"""
     self.assertEqual(CsvOperations.read_data(self.file_name)[0], ["1", "Gold", "10"])
     self.assertEqual(CsvOperations.read_data(self.file_name)[1], ["2", "Platinum", "5"])
     self.assertEqual(CsvOperations.read_data(self.file_name)[2], ["3", "Bronze", "0"])
Пример #5
0
 def test_read_inexistent_file(self):
     """ test that none data is returned when inexistent file is read"""
     self.assertEqual(CsvOperations.read_data(self.inexistent_file), None)
Пример #6
0
 def test_read_empty_file(self):
     """ test that empty list is returned when an empty file is read"""
     self.assertEqual(CsvOperations.read_data(self.empty_file), [])