def test_handle_writes_to_correct_location_when_output_file_not_specified(self, course_key, patched_get_course):
     """ Tests that when no explicit filename is given data is exported to default location """
     self.set_up_default_mocks(patched_get_course)
     expected_filename = utils.format_filename(
         "social_stats_{course}_{date:%Y_%m_%d_%H_%M_%S}.csv".format(course=course_key, date=datetime.utcnow())
     )
     patched_open = mock.mock_open()
     with mock.patch("{}.open".format(_target_module), patched_open, create=True), \
             mock.patch(_target_module + ".Extractor.extract") as patched_extractor:
         patched_extractor.return_value = []
         self.command.handle(course_key)
         patched_open.assert_called_with(expected_filename, 'wb')
Esempio n. 2
0
 def test_handle_writes_to_correct_location_when_output_file_not_specified(
         self, course_key, patched_get_course, patched_get_settings):
     """ Tests that when no explicit filename is given data is exported to default location """
     self.set_up_default_mocks(patched_get_course, patched_get_settings)
     expected_filename = utils.format_filename(
         "social_stats_{course}_{date:%Y_%m_%d_%H_%M_%S}.csv".format(
             course=course_key, date=datetime.utcnow()))
     patched_open = mock.mock_open()
     with mock.patch("{}.open".format(_target_module), patched_open, create=True), \
             mock.patch(_target_module + ".Extractor.extract") as patched_extractor:
         patched_extractor.return_value = []
         self.command.handle(course_key)
         patched_open.assert_called_with(expected_filename, 'wb')
 def get_default_file_location(self, course_key):
     """ Builds default destination file name """
     return utils.format_filename(
         "social_stats_{course}_{date:%Y_%m_%d_%H_%M_%S}.csv".format(course=course_key, date=datetime.utcnow())
     )
Esempio n. 4
0
 def get_default_file_location(self, course_key):
     """ Builds default destination file name """
     return utils.format_filename(
         "social_stats_{course}_{date:%Y_%m_%d_%H_%M_%S}.csv".format(
             course=course_key, date=datetime.utcnow()))