def test_no_overwrite(self): # kwargs = {'overwrite': False} kwargs = {} task = ImportStudentCourseEnrollmentTask(**kwargs) with patch('edx.analytics.tasks.insights.database_imports.HivePartitionTarget') as mock_target: output = mock_target() # Make MagicMock act more like a regular mock, so that flatten() does the right thing. del output.__iter__ del output.__getitem__ output.exists = Mock(return_value=False) self.assertFalse(task.complete()) self.assertTrue(output.exists.called) output.exists = Mock(return_value=True) self.assertTrue(task.complete()) self.assertTrue(output.exists.called)
def test_no_overwrite(self): kwargs = {} task = ImportStudentCourseEnrollmentTask(**kwargs) with patch('edx.analytics.tasks.insights.database_imports.HivePartitionTarget') as mock_target: output = mock_target() # Make MagicMock act more like a regular mock, so that flatten() does the right thing. del output.__iter__ del output.__getitem__ output.exists = Mock(return_value=False) self.assertFalse(task.complete()) self.assertTrue(output.exists.called) output.exists = Mock(return_value=True) self.assertTrue(task.complete()) self.assertTrue(output.exists.called)
def test_overwrite(self): kwargs = {'overwrite': True} task = ImportStudentCourseEnrollmentTask(**kwargs) self.assertFalse(task.complete())