def setUp(self):
   super(FunctionalTests, self).setUp()
   clever.api_base = os.environ.get('CLEVER_API_BASE', 'https://api.clever.com')
   if auth.get("token", None):
     clever.set_token(auth["token"])
   elif auth.get("api_key", None):
     clever.set_api_key(auth["api_key"])
Example #2
0
 def test_invalid_credentials(self):
   token = clever.get_token()
   try:
     clever.set_token('invalid')
     clever.District.all()
   except clever.AuthenticationError, e:
     self.assertEqual(401, e.http_status)
     self.assertTrue(isinstance(e.http_body, str))
     self.assertTrue(isinstance(e.json_body, dict))
Example #3
0
 def setUp(self):
     super(CleverTestCase, self).setUp()
     clever.set_token('DEMO_TOKEN')
Example #4
0
from auth import auth, login_required
from flask import Flask, abort, session
from jinja2 import Environment, FileSystemLoader

import constants


app = Flask(__name__)
app.register_blueprint(auth)
# Sets the secret key for session cookie encryption
app.secret_key = constants.SESSION_SECRET_KEY

env = Environment(loader=FileSystemLoader('templates'))

# Sets the Clever OAUTH token for a specific district
clever.set_token(constants.OAUTH_TOKEN)


@app.route('/')
def main():
  template = env.get_template('index.html')
  return template.render()


@app.route('/schedule')
@login_required
def show_schedule():
  """Displays the bell schedule."""

  if session['type'] == 'student':
    field = 'students'
Example #5
0
import clever
clever.set_token('6c6fe12c1fc88de03a2612c93634b32ed7452638')

contacts = clever.Student.all()
print contacts
Example #6
0
import clever

clever.set_token("DEMO_TOKEN")
sections = clever.Section.all()
sum([len(s.students) for s in sections])/float(len(sections))
Example #7
0
 def setUp(self):
   super(CleverTestCase, self).setUp()
   clever.api_base = os.environ.get('CLEVER_API_BASE', 'https://api.clever.com')
   clever.set_token('DEMO_TOKEN')
Example #8
0
 def setUp(self):
   super(FunctionalTests, self).setUp()
   clever.api_base = os.environ.get('CLEVER_API_BASE', 'https://api.clever.com')
   if auth.get("token", None):
     clever.set_token(auth["token"])
Example #9
0
    district = clever.District.all(where=json.dumps({'name': 'asdf'}))
    self.assertEqual(district, [])

class AuthenticationErrorTest(CleverTestCase):

  def test_invalid_credentials(self):
    token = clever.get_token()
    try:
      clever.set_token('invalid')
      clever.District.all()
    except clever.AuthenticationError, e:
      self.assertEqual(401, e.http_status)
      self.assertTrue(isinstance(e.http_body, str))
      self.assertTrue(isinstance(e.json_body, dict))
    finally:
      clever.set_token(token)


class InvalidRequestErrorTest(CleverTestCase):

  def test_nonexistent_object(self):
    try:
      clever.District.retrieve('invalid')
    except clever.APIError, e:
      self.assertEqual(404, e.http_status)
      self.assertFalse(isinstance(e.json_body, dict))  # 404 does not have a body
      self.assertTrue(isinstance(e.http_body, str))

#generates httmock responses for TooManyRequestsErrorTest
def too_many_requests_content(url, request):
  headers =  {