def test_exclude_subrecords( self, write_data_dictionary, write_to_file, csv_renderer, subrecords ): subrecords.return_value = [Colour] extract.generate_csv_files( "somewhere", models.Episode.objects.all(), self.user ) self.assertEqual(csv_renderer.call_count, 0)
def test_generate_csv_files(self, write_data_dictionary, write_to_file, subrecords): patient, episode = self.new_patient_and_episode_please() subrecords.return_value = [HatWearer, HouseOwner] HatWearer.objects.create(name="Indiana", episode=episode) HouseOwner.objects.create(patient=patient) results = extract.generate_csv_files("somewhere", models.Episode.objects.all(), self.user) expected = [('somewhere/data_dictionary.html', 'data_dictionary.html'), ('somewhere/episodes.csv', 'episodes.csv'), ('somewhere/hat_wearer.csv', 'hat_wearer.csv'), ('somewhere/house_owner.csv', 'house_owner.csv')] self.assertEqual(expected, results) self.assertEqual(write_data_dictionary.call_args[0][0], 'somewhere/data_dictionary.html') self.assertEqual(write_to_file.call_args[0], ('somewhere/house_owner.csv', ))
def test_generate_csv_files( self, write_data_dictionary, write_to_file, subrecords ): patient, episode = self.new_patient_and_episode_please() subrecords.return_value = [HatWearer, HouseOwner] HatWearer.objects.create(name="Indiana", episode=episode) HouseOwner.objects.create(patient=patient) results = extract.generate_csv_files( "somewhere", models.Episode.objects.all(), self.user ) expected = [ ('somewhere/data_dictionary.html', 'data_dictionary.html'), ('somewhere/episodes.csv', 'episodes.csv'), ('somewhere/hat_wearer.csv', 'hat_wearer.csv'), ('somewhere/house_owner.csv', 'house_owner.csv') ] self.assertEqual(expected, results) self.assertEqual( write_data_dictionary.call_args[0][0], 'somewhere/data_dictionary.html' ) self.assertEqual( write_to_file.call_args[0], ('somewhere/house_owner.csv',) )