Testing file saving in save_record()

To demonstrate how to test file-writing with mock_open, let's test save_record():

    @patch('abq_data_entry.models.os.path.exists')
    def test_save_record(self, mock_exists):

To test the conversion from a dict to a csv string, we'll need a sample record in both formats:

        record = {
            "Date": '2018-07-01', "Time": '12:00',             "Technician": 'Test Tech', "Lab": 'E',              "Plot": '7', "Seed sample": 'test',            "Humidity": '10', "Light": '99',             "Temperature": '20', "Equipment Fault": False,            "Plants": '10', "Blossoms": '200', "Fruit": '250',             "Min Height": '40', "Max Height": '50',            "Median Height": '55', "Notes": 'Test Note\r\nTest Note\r\n'}
        record_as_csv = (
            '2018-07-01,12:00,Test Tech,E,17,test,10,99,20,False,' '10,200,250,40,50,55,"Test ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.