10
10
11
11
try :
12
12
import httplib2
13
+ import pandas .io .ga as ga
13
14
from pandas .io .ga import GAnalytics , read_ga
14
- from pandas .io .auth import AuthenticationConfigError , reset_token_store
15
+ from pandas .io .auth import AuthenticationConfigError , reset_default_token_store
15
16
from pandas .io import auth
16
17
except ImportError :
17
18
raise nose .SkipTest ("need httplib2 and auth libs" )
@@ -25,7 +26,7 @@ def test_remove_token_store(self):
25
26
with open (auth .DEFAULT_TOKEN_FILE , 'w' ) as fh :
26
27
fh .write ('test' )
27
28
28
- reset_token_store ()
29
+ reset_default_token_store ()
29
30
self .assert_ (not os .path .exists (auth .DEFAULT_TOKEN_FILE ))
30
31
31
32
@slow
@@ -98,6 +99,26 @@ def test_iterator(self):
98
99
except AuthenticationConfigError :
99
100
raise nose .SkipTest ("authentication error" )
100
101
102
+ def test_v2_advanced_segment_format (self ):
103
+ advanced_segment_id = 1234567
104
+ query = ga .format_query ('google_profile_id' , ['visits' ], '2013-09-01' , segment = advanced_segment_id )
105
+ assert query ['segment' ] == 'gaid::' + str (advanced_segment_id ), "An integer value should be formatted as an advanced segment."
106
+
107
+ def test_v2_dynamic_segment_format (self ):
108
+ dynamic_segment_id = 'medium==referral'
109
+ query = ga .format_query ('google_profile_id' , ['visits' ], '2013-09-01' , segment = dynamic_segment_id )
110
+ assert query ['segment' ] == 'dynamic::ga:' + str (dynamic_segment_id ), "A string value with more than just letters and numbers should be formatted as a dynamic segment."
111
+
112
+ def test_v3_advanced_segment_common_format (self ):
113
+ advanced_segment_id = 'aZwqR234'
114
+ query = ga .format_query ('google_profile_id' , ['visits' ], '2013-09-01' , segment = advanced_segment_id )
115
+ assert query ['segment' ] == 'gaid::' + str (advanced_segment_id ), "A string value with just letters and numbers should be formatted as an advanced segment."
116
+
117
+ def test_v3_advanced_segment_weird_format (self ):
118
+ advanced_segment_id = 'aZwqR234-s1'
119
+ query = ga .format_query ('google_profile_id' , ['visits' ], '2013-09-01' , segment = advanced_segment_id )
120
+ assert query ['segment' ] == 'gaid::' + str (advanced_segment_id ), "A string value with just letters, numbers, and hyphens should be formatted as an advanced segment."
121
+
101
122
@slow
102
123
@with_connectivity_check ("http://www.google.com" )
103
124
def test_segment (self ):
0 commit comments