[385] Use page_heading helper function consistently
[ckanext-ga-report.git] / ckanext / ga_report / tests / test_auth.py
Ross Jones








































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from nose.tools import assert_equal
from ckanext.ga_report.ga_auth import (init_service, get_profile_id)
 
class TestAuth:
 
    @classmethod
    def setup_class(cls):
        if not os.path.exists("token.dat") or not os.path.exists("credentials.json"):
            print '*' * 60
            print "Tests may not run without first having run the auth process"
            print '*' * 60
 
    @classmethod
    def teardown_class(cls):
        pass
 
    def test_init(self):
        try:
            res = init_service(None, None)
            assert False, "Init service worked without credentials or tokens"
        except TypeError:
            pass
 
    def test_init_with_token(self):
        res = init_service("token.dat", None)
        assert res is not None, "Init service worked without credentials"
 
    def test_init_with_token_and_credentials(self):
        res = init_service("token.dat", "credentials.json")
        assert res is not None, "Unable to create service with valid details"
 
    def test_init_with_redentials(self):
        #res = init_service("", "credentials.json")
        # Triggers the auth flow via the browser
        pass
 
    def test_get_profile(self):
        svc = init_service("token.dat", "credentials.json")
        profile = get_profile_id(svc)
        assert profile is not None, "Unable to find a profile given configured UA id and user details"