コード例 #1
0
 def test_accountlist(self):
   Connection = googleanalytics.Connection
   connection = Connection()
   valid_profile_ids = config.get_valid_profiles()
   for c in range(1, len(valid_profile_ids)):
     accounts = connection.get_accounts(max_results=c)
     assert len(accounts) == c
コード例 #2
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
    def test_dimensions_basic_get_data(self):
        Connection = googleanalytics.Connection
        connection = Connection()
        valid_profile_ids = config.get_valid_profiles()

        start_date = datetime.date(2009, 04, 10)
        end_date = datetime.date(2009, 04, 10)

        for c in range(len(valid_profile_ids)):
            account = connection.get_account(valid_profile_ids[c])
            data = account.get_data(start_date=start_date,
                                    end_date=end_date,
                                    dimensions=[
                                        'browser',
                                    ],
                                    metrics=[
                                        'pageviews',
                                    ])
            assert len(data) > 0
            data = account.get_data(start_date=start_date,
                                    end_date=end_date,
                                    dimensions=[
                                        'pagePath',
                                    ],
                                    metrics=[
                                        'pageviews',
                                    ])
            assert len(data) > 0
コード例 #3
0
 def test_account_retrieval_unvalidated(self):
   Connection = googleanalytics.Connection
   connection = Connection()
   valid_profile_ids = config.get_valid_profiles()
   for c in range(len(valid_profile_ids)):
     account = connection.get_account(valid_profile_ids[c])
   account_list = connection.get_accounts()
コード例 #4
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
    def test_dimensions_basic_get_data_output(self):
        Connection = googleanalytics.Connection
        connection = Connection()
        valid_profile_ids = config.get_valid_profiles()

        start_date = datetime.date(2009, 04, 10)
        end_date = datetime.date(2009, 04, 10)

        for c in range(len(valid_profile_ids)):
            account = connection.get_account(valid_profile_ids[c])
            data = account.get_data(start_date=start_date,
                                    end_date=end_date,
                                    dimensions=[
                                        'browser',
                                    ],
                                    metrics=[
                                        'pageviews',
                                    ],
                                    sort=[
                                        '-pageviews',
                                    ])
            assert len(data) > 0
            assert isinstance(data.list, list)
            assert isinstance(data.list[0], list)
            assert isinstance(data.tuple, tuple)
            assert isinstance(data.tuple[0], tuple)
            assert isinstance(data.dict, dict)
コード例 #5
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
 def test_accountlist(self):
     Connection = googleanalytics.Connection
     connection = Connection()
     valid_profile_ids = config.get_valid_profiles()
     for c in range(1, len(valid_profile_ids)):
         accounts = connection.get_accounts(max_results=c)
         assert len(accounts) == c
コード例 #6
0
 def test_basic_get_data_no_params(self):
   Connection = googleanalytics.Connection
   connection = Connection()
   valid_profile_ids = config.get_valid_profiles()
   
   start_date = datetime.date(2009, 04, 10)
   end_date = datetime.date(2009, 04, 10)
   
   for c in range(len(valid_profile_ids)):
     account = connection.get_account(valid_profile_ids[c])
     data = account.get_data(start_date=start_date, end_date=end_date)
     assert len(data) == 0
コード例 #7
0
 def test_bad_date_order(self):
   Connection = googleanalytics.Connection
   connection = Connection()
   valid_profile_ids = config.get_valid_profiles()
   
   start_date = datetime.date(2009, 02, 21)
   end_date = datetime.date(2009, 02, 20)
   account = connection.get_account(valid_profile_ids[0])
   try:
     data = account.get_data(start_date=start_date, end_date=end_date)
   except GoogleAnalyticsClientError, e:
     assert str(e.reason) == "Date orders are reversed"
コード例 #8
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
    def test_basic_get_data_no_params(self):
        Connection = googleanalytics.Connection
        connection = Connection()
        valid_profile_ids = config.get_valid_profiles()

        start_date = datetime.date(2009, 04, 10)
        end_date = datetime.date(2009, 04, 10)

        for c in range(len(valid_profile_ids)):
            account = connection.get_account(valid_profile_ids[c])
            data = account.get_data(start_date=start_date, end_date=end_date)
            assert len(data) == 0
コード例 #9
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
    def test_bad_date_order(self):
        Connection = googleanalytics.Connection
        connection = Connection()
        valid_profile_ids = config.get_valid_profiles()

        start_date = datetime.date(2009, 02, 21)
        end_date = datetime.date(2009, 02, 20)
        account = connection.get_account(valid_profile_ids[0])
        try:
            data = account.get_data(start_date=start_date, end_date=end_date)
        except GoogleAnalyticsClientError, e:
            assert str(e.reason) == "Date orders are reversed"
コード例 #10
0
 def test_dimensions_basic_get_data(self):
   Connection = googleanalytics.Connection
   connection = Connection()
   valid_profile_ids = config.get_valid_profiles()
 
   start_date = datetime.date(2009, 04, 10)
   end_date = datetime.date(2009, 04, 10)
 
   for c in range(len(valid_profile_ids)):
     account = connection.get_account(valid_profile_ids[c])
     data = account.get_data(start_date=start_date, end_date=end_date, dimensions=['browser',], metrics=['pageviews',])
     assert len(data) > 0
     data = account.get_data(start_date=start_date, end_date=end_date, dimensions=['pagePath',], metrics=['pageviews',])
     assert len(data) > 0
コード例 #11
0
  def test_multiple_dimensions(self):
    Connection = googleanalytics.Connection
    connection = Connection()
    valid_profile_ids = config.get_valid_profiles()

    end_date = datetime.datetime.today()
    start_date = end_date-datetime.timedelta(days=2)

    for c in range(len(valid_profile_ids)):
      account = connection.get_account(valid_profile_ids[c])
      data = account.get_data(start_date=start_date, end_date=end_date, dimensions=['pageTitle', 'pagePath'], metrics=['pageviews','timeOnPage','entrances'], max_results=10)
      for t in data.tuple:
        #print t
        assert len(t) == 2
        assert len(t[0]) == 2
        assert len(t[1]) == 3
コード例 #12
0
  def test_paging(self):
    Connection = googleanalytics.Connection
    connection = Connection()
    valid_profile_ids = config.get_valid_profiles()

    end_date = datetime.datetime.today()
    start_date = end_date-datetime.timedelta(days=2)

    for c in range(len(valid_profile_ids)):
      account = connection.get_account(valid_profile_ids[c])
      data1 = account.get_data(start_date=start_date, end_date=end_date, dimensions=['pageTitle', 'pagePath'], metrics=['pageviews',], sort=['-pageviews',], max_results=10)
      assert len(data1) == 10
      data2 = account.get_data(start_date=start_date, end_date=end_date, dimensions=['pageTitle', 'pagePath'], metrics=['pageviews',], sort=['-pageviews',], max_results=10, start_index=11)
      #print data2.tuple
      assert len(data2) == 10
      for value in data1.tuple:
      	assert value not in data2
コード例 #13
0
  def test_dimensions_basic_get_data_output(self):
    Connection = googleanalytics.Connection
    connection = Connection()
    valid_profile_ids = config.get_valid_profiles()

    start_date = datetime.date(2009, 04, 10)
    end_date = datetime.date(2009, 04, 10)

    for c in range(len(valid_profile_ids)):
      account = connection.get_account(valid_profile_ids[c])
      data = account.get_data(start_date=start_date, end_date=end_date, dimensions=['browser',], metrics=['pageviews',], sort=['-pageviews',])
      assert len(data) > 0
      assert isinstance(data.list, list)
      assert isinstance(data.list[0], list)
      assert isinstance(data.tuple, tuple)
      assert isinstance(data.tuple[0], tuple)
      assert isinstance(data.dict, dict)
コード例 #14
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
    def test_multiple_dimensions(self):
        Connection = googleanalytics.Connection
        connection = Connection()
        valid_profile_ids = config.get_valid_profiles()

        end_date = datetime.datetime.today()
        start_date = end_date - datetime.timedelta(days=2)

        for c in range(len(valid_profile_ids)):
            account = connection.get_account(valid_profile_ids[c])
            data = account.get_data(
                start_date=start_date,
                end_date=end_date,
                dimensions=['pageTitle', 'pagePath'],
                metrics=['pageviews', 'timeOnPage', 'entrances'],
                max_results=10)
            for t in data.tuple:
                #print t
                assert len(t) == 2
                assert len(t[0]) == 2
                assert len(t[1]) == 3
コード例 #15
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
    def test_paging(self):
        Connection = googleanalytics.Connection
        connection = Connection()
        valid_profile_ids = config.get_valid_profiles()

        end_date = datetime.datetime.today()
        start_date = end_date - datetime.timedelta(days=2)

        for c in range(len(valid_profile_ids)):
            account = connection.get_account(valid_profile_ids[c])
            data1 = account.get_data(start_date=start_date,
                                     end_date=end_date,
                                     dimensions=['pageTitle', 'pagePath'],
                                     metrics=[
                                         'pageviews',
                                     ],
                                     sort=[
                                         '-pageviews',
                                     ],
                                     max_results=10)
            assert len(data1) == 10
            data2 = account.get_data(start_date=start_date,
                                     end_date=end_date,
                                     dimensions=['pageTitle', 'pagePath'],
                                     metrics=[
                                         'pageviews',
                                     ],
                                     sort=[
                                         '-pageviews',
                                     ],
                                     max_results=10,
                                     start_index=11)
            #print data2.tuple
            assert len(data2) == 10
            for value in data1.tuple:
                assert value not in data2
コード例 #16
0
ファイル: tests.py プロジェクト: Matt-Sartain/AAN
 def test_account_retrieval_unvalidated(self):
     Connection = googleanalytics.Connection
     connection = Connection()
     valid_profile_ids = config.get_valid_profiles()
     for c in range(len(valid_profile_ids)):
         account = connection.get_account(valid_profile_ids[c])
コード例 #17
0
 def setUp(self):
     self.connection = googleanalytics.Connection()
     self.valid_profile_ids = config.get_valid_profiles()
     self.end_date = datetime.date.today()
     self.start_date = self.end_date - datetime.timedelta(30)
コード例 #18
0
 def setUp(self):
     self.connection = googleanalytics.Connection()
     self.valid_profile_ids = config.get_valid_profiles()
     self.end_date = datetime.date.today()
     self.start_date = self.end_date - datetime.timedelta(30)