Beispiel #1
0
    def test_env_var_priority(self):
        conn = SqliteHook.get_connection(conn_id='airflow_db')
        self.assertNotEqual('ec2.compute.com', conn.host)

        with mock.patch.dict('os.environ', {
            'AIRFLOW_CONN_AIRFLOW_DB': 'postgres://*****:*****@ec2.compute.com:5432/the_database',
        }):
            conn = SqliteHook.get_connection(conn_id='airflow_db')
            self.assertEqual('ec2.compute.com', conn.host)
            self.assertEqual('the_database', conn.schema)
            self.assertEqual('username', conn.login)
            self.assertEqual('password', conn.password)
            self.assertEqual(5432, conn.port)
 def test_using_unix_socket_env_var(self):
     conn = SqliteHook.get_connection(conn_id='test_uri_no_creds')
     self.assertEqual('ec2.compute.com', conn.host)
     self.assertEqual('the_database', conn.schema)
     self.assertIsNone(conn.login)
     self.assertIsNone(conn.password)
     self.assertIsNone(conn.port)
 def test_using_env_var(self):
     conn = SqliteHook.get_connection(conn_id='test_uri')
     self.assertEqual('ec2.compute.com', conn.host)
     self.assertEqual('the_database', conn.schema)
     self.assertEqual('username', conn.login)
     self.assertEqual('password', conn.password)
     self.assertEqual(5432, conn.port)
Beispiel #4
0
    def test_env_var_priority(self):
        conn = SqliteHook.get_connection(conn_id='airflow_db')
        assert 'ec2.compute.com' != conn.host

        with mock.patch.dict(
            'os.environ',
            {
                'AIRFLOW_CONN_AIRFLOW_DB': 'postgres://*****:*****@ec2.compute.com:5432/the_database',
            },
        ):
            conn = SqliteHook.get_connection(conn_id='airflow_db')
            assert 'ec2.compute.com' == conn.host
            assert 'the_database' == conn.schema
            assert 'username' == conn.login
            assert 'password' == conn.password
            assert 5432 == conn.port
Beispiel #5
0
 def test_using_unix_socket_env_var(self):
     conn = SqliteHook.get_connection(conn_id='test_uri_no_creds')
     assert 'ec2.compute.com' == conn.host
     assert 'the_database' == conn.schema
     assert conn.login is None
     assert conn.password is None
     assert conn.port is None
Beispiel #6
0
 def test_using_env_var(self):
     conn = SqliteHook.get_connection(conn_id='test_uri')
     assert 'ec2.compute.com' == conn.host
     assert 'the_database' == conn.schema
     assert 'username' == conn.login
     assert 'password' == conn.password
     assert 5432 == conn.port