'Test that, once a DAG is loaded, it doesn\'t get refreshed again if it
hasn\'t been expired.'

@patch.object(DagModel, u'get_current')
def test_get_dag_without_refresh(self, mock_dagmodel):

    dag_id = u'example_bash_operator'
    mock_dagmodel.return_value = DagModel()
    mock_dagmodel.return_value.last_expired = None
    mock_dagmodel.return_value.fileloc = u'foo'
    class TestDagBag(models.DagBag, ):
        process_file_calls = 0
        def process_file(self, filepath, only_if_updated=True, safe_mode=True):
            if (u'example_bash_operator.py' == os.path.basename(filepath)):
                TestDagBag.process_file_calls += 1
            super(TestDagBag, self).process_file(filepath, only_if_updated, safe_mode)
    dagbag = TestDagBag(include_examples=True)
    processed_files = dagbag.process_file_calls
    self.assertEqual(1, dagbag.process_file_calls)
    self.assertIsNotNone(dagbag.get_dag(dag_id))
    self.assertEqual(1, dagbag.process_file_calls)
