Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a settings file for testing.

  • Loading branch information...
commit 14259dc41fe8f6d29b4d95d10a243933a8e2b624 1 parent 612831e
Chris Le authored
Showing with 29 additions and 37 deletions.
  1. +6 −37 test/test_engine.rb
  2. +23 −0 test/test_results.rb
View
43 test/test_engine.rb
@@ -1,24 +1,17 @@
require File.expand_path('../helper', __FILE__)
+require File.expand_path('../settings', __FILE__)
class TestEngine < Test::Unit::TestCase
- DEFAULT_AUTH = {
- :email => 'test@gmail.com',
- :password => 'password',
- :debug => false
- }
- DEFAULT_QUERY = {
- :start_date => '2010-01-01',
- :end_date => '2011-01-01',
- :dimensions => ['date'],
- :metrics => ['visits']
- }
- PROFILE_ID = 12345678
-
def test_login_with_good_password
assert Gattica.new(@auth), "should have been able to login"
end
+ def test_low_timeout
+ ga = Gattica.new(GatticaTest::DEFAULT_AUTH.merge!({ :debug =>false, :timeout => 1 }))
+ puts ga.accounts.inspect
+ end
+
def test_login_with_bad_user_password
assert_raise GatticaError::CouldNotAuthenticate do
Gattica.new({ :email => 'bad-email@gmail.com', :password => 'bad-password'})
@@ -36,28 +29,4 @@ def test_use_an_existing_token
assert Gattica.new({ :token => token })
end
- def test_max_results
- response = ga_get({ :max_results => 5 })
- assert response.points.count == 5, "should only return 5 results"
- end
-
- def test_start_index
- response = ga_get({ :start_index => 5, :max_results => 5 })
- assert response.points.first.title == "ga:date=20100105", "should start on the 5th"
- end
-
-private
-
- def ga(options={}, profile_id=PROFILE_ID)
- unless defined? @ga
- @ga = Gattica.new(DEFAULT_AUTH)
- @ga.profile_id = profile_id
- end
- @ga
- end
-
- def ga_get(options={}, profile_id=PROFILE_ID)
- ga.get(DEFAULT_QUERY.merge(options))
- end
-
end
View
23 test/test_results.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../helper', __FILE__)
+require File.expand_path('../settings', __FILE__)
+
+class TestResults < Test::Unit::TestCase
+
+ def setup
+ @response = GatticaTest::get({ :start_index => 5, :max_results => 5 })
+ end
+
+ def test_max_results
+ assert @response.points.count == 5, "should only return 5 results"
+ end
+
+ def test_start_index
+ assert @response.points.first.title == "ga:date=20100105", "should start on the 5th"
+ end
+
+ def test_conversions
+ assert @response.class.inspect == 'Gattica::DataSet', "should be a Gattica:DataSet"
+ assert @response.to_h.class.inspect == 'Hash', "Should be a hash"
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.