Esempio n. 1
0
def main():
    conn = Connection(settings.SODA_MASTER_APPID, settings.HV_SERVICE_SERVER)

    method = NewApplicationCreationInfo()
    method.execute(conn)

    app_token = method.response.app_token

    qs = {}
    qs['appCreationToken'] = app_token
    qs['appid'] = conn.applicationid
    qs['instanceName'] = 'PythonSoda'

    target_qs = urllib.urlencode(qs)
    target_qs = urllib.quote_plus(target_qs)
    app_creation_url = '%s/redirect.aspx?target=CREATEAPPLICATION&targetqs=%s'
    req_url = app_creation_url % (settings.HV_SHELL_URL, target_qs)
    print req_url
    webbrowser.open(req_url)
    print 'Press enter after auth'
    raw_input()

    conn.applicationid = method.response.app_id
    conn.soda_shared_secret = method.response.shared_secret

    conn.connect()

    getpeople = GetAuthorizedPeople(GetAuthorizedPeopleParameters())
    getpeople.execute(conn)

    print 'Welcome to SODA, %s' % getpeople.response.authorized_people[0].name
    def test_getauthroizedpeople(self):
        method = GetAuthorizedPeople(GetAuthorizedPeopleParameters())
        method.execute(self.connection)

        response = method.response

        self.assertNotEqual(len(response.authorized_people), 0)
        self.assertIsNotNone(response.authorized_people[0].name)
        self.assertNotEqual(len(response.authorized_people[0].records), 0)
    def test_getauthroizedpeople_with_num(self):
        params = GetAuthorizedPeopleParameters()
        params.num_results = 1
        method = GetAuthorizedPeople(params)
        method.execute(self.connection)

        response = method.response

        self.assertIsNotNone(response)
        self.assertEqual(len(response.authorized_people), 1)
    def test_getauthroizedpeople_with_since(self):
        params = GetAuthorizedPeopleParameters()
        params.authorizations_created_since = datetime.now(pytz.utc)
        method = GetAuthorizedPeople(params)
        method.execute(self.connection)

        response = method.response

        self.assertIsNotNone(response)
        self.assertEqual(len(response.authorized_people), 0)