Example #1
0
from env_setup import setup_django; setup_django()

import json

from restler.serializers import to_json


def flip(*args, **kwargs):
    return json.loads(to_json(*args, **kwargs))
Example #2
0
""" Run tests using unittest2 'discover' """
import os
import sys
import getopt

import env_setup

env_setup.setup_django()


def usage():
    print """{}
Usage: python manage.py test

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
  -f, --failfast   Stop on first failure
  -c, --catch      Catch control-C and display results
  -b, --buffer     Buffer stdout and stderr during test runs

""".format(__doc__)


__unittest = True
try:
    from unittest2.main import main_ as main
except ImportError:
    from unittest.main import main
import env_setup; env_setup.setup_tests(); env_setup.setup_django()

from agar.test import BaseTest, WebTest

import main


class MainTest(BaseTest, WebTest):

    APPLICATION = main.application

    def test_hello_world(self):
        response = self.get("/")
        self.assertOK(response)
Example #4
0
#!/usr/bin/env python

from env_setup import setup_django
setup_django()

from django import forms

from agar.django.decorators import validate_service
from agar.django.forms import StrictRequestForm
from agar.json import MultiPageHandler
from agar.json import config as agar_json_config

from restler import serializers

from webapp2 import WSGIApplication, Route

from tests.models import Model1


V1_SERVICE_STRATEGY = serializers.ModelStrategy(Model1)
V1_SERVICE_STRATEGY = V1_SERVICE_STRATEGY + ['string', 'boolean', 'phonenumber']
V2_SERVICE_STRATEGY = V1_SERVICE_STRATEGY - ["boolean", "phonenumber"]


def create_sample_data(page_size=agar_json_config.DEFAULT_PAGE_SIZE):
    count = Model1.all().count()
    while count < page_size + 1:
        model1 = Model1(string='test entry %s'% count)
        model1.put()
        count += 1