-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensuring we don't override existing sessions
- Loading branch information
Showing
2 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
from astroquery.query import BaseQuery, BaseVOQuery | ||
|
||
|
||
class with_VO(BaseVOQuery, BaseQuery): | ||
pass | ||
|
||
|
||
class without_VO(BaseQuery): | ||
pass | ||
|
||
|
||
class only_VO(BaseVOQuery): | ||
pass | ||
|
||
|
||
def test_session_VO_header(): | ||
test_instance = with_VO() | ||
user_agent = test_instance._session.headers['User-Agent'] | ||
assert 'astroquery' in user_agent | ||
assert 'pyVO' in user_agent | ||
assert user_agent.count('astroquery') == 1 | ||
|
||
|
||
def test_session_nonVO_header(): | ||
test_instance = without_VO() | ||
user_agent = test_instance._session.headers['User-Agent'] | ||
assert 'astroquery' in user_agent | ||
assert 'pyVO' not in user_agent | ||
assert user_agent.count('astroquery') == 1 | ||
|
||
|
||
def test_session_hooks(): | ||
# Test that we don't override the session in the BaseVOQuery | ||
test_instance = with_VO() | ||
assert len(test_instance._session.hooks['response']) > 0 | ||
|
||
test_VO_instance = only_VO() | ||
assert len(test_VO_instance._session.hooks['response']) == 0 |