Exemplo n.º 1
0
def home(request):
    api = CSEAPI()
    products = api.get_products()

    return render_to_response('page/home.html',
                              dict(products=products),
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
    def test_get_products(self):
        api = CSEAPI()

        # Test for radom products.
        products = api.get_products()
        for product in products:
            self.assertIsInstance(product.id, int)
            self.assertTrue(product.type in ['app', 'website', 'game'])
Exemplo n.º 3
0
    def test_get_products(self):
        api = CSEAPI()

        # Test for radom products.
        products = api.get_products()
        for product in products:
            self.assertIsInstance(product.id, int)
            self.assertTrue(product.type in ['app', 'website', 'game'])
Exemplo n.º 4
0
    def test_get_product_by_slug(self):
        api = CSEAPI()

        # Test for a product by review URL slug.
        slug = 'game/winds-of-orbis'
        product = api.get_product_by_slug(slug)
        self.assertIsInstance(product.id, int)
        self.assertTrue(product.type, 'game')
        self.assertTrue((slug in product.review.url))
Exemplo n.º 5
0
    def test_get_product_by_slug(self):
        api = CSEAPI()

        # Test for a product by review URL slug.
        slug = 'game/winds-of-orbis'
        product = api.get_product_by_slug(slug)
        self.assertIsInstance(product.id, int)
        self.assertTrue(product.type, 'game')
        self.assertTrue((slug in product.review.url))
Exemplo n.º 6
0
    def test_get_product(self):
        api = CSEAPI()

        # Get a product from the products API.
        products = api.get_products()
        product = api.get_product(products[0].id)

        self.assertEquals(product.id, products[0].id)
        self.assertEquals(product.title, products[0].title)
        self.assertEquals(product.type, products[0].type)
Exemplo n.º 7
0
    def test_get_product(self):
        api = CSEAPI()

        # Get a product from the products API.
        products = api.get_products()
        product = api.get_product(products[0].id)

        self.assertEquals(product.id, products[0].id)
        self.assertEquals(product.title, products[0].title)
        self.assertEquals(product.type, products[0].type)
Exemplo n.º 8
0
    def test_request(self):
        api = CSEAPI()
        endpoint = '/v3/educator/products'

        # Test invalid auth request.
        data = api.request(endpoint, {'clientId': 'qwer'})
        self.assertEquals(data.statusCode, 401)

        # Test valid endpoint.
        data = api.request(endpoint)
        self.assertEquals(data.statusCode, 200)
        self.assertIsInstance(data.response, list)
Exemplo n.º 9
0
    def test_request(self):
        api = CSEAPI()
        endpoint = '/v3/educator/products'

        # Test invalid auth request.
        data = api.request(endpoint, { 'clientId': 'qwer' })
        self.assertEquals(data.statusCode, 401)

        # Test valid endpoint.
        data = api.request(endpoint)
        self.assertEquals(data.statusCode, 200)
        self.assertIsInstance(data.response, list)
Exemplo n.º 10
0
def view(request, slug):
    api = CSEAPI()
    product = api.get_product_by_slug(slug)

    payload = {
        'product': product,
        'review': product.review,
    }

    # print product.review.author

    return render_to_response('review/view.html', payload, context_instance=RequestContext(request))
Exemplo n.º 11
0
def view(request, slug):
    api = CSEAPI()
    user = api.get_user_by_slug(slug)
    flows = api.get_nodes('flow', { 'author_id': user.id, 'status': 1 })
    boards = api.get_nodes('board', { 'author_id': user.id, 'status': 1 })

    payload = {
        'user': user,
        'flows': flows,
        'boards': boards,
    }

    return render_to_response('user/view.html', payload, context_instance=RequestContext(request))
Exemplo n.º 12
0
    def test_get_nodes(self):
        api = CSEAPI()

        # Test various node types.
        nodes = api.get_nodes('flow')
        for node in nodes:
            self.assertEquals(node.type, 'flow')

        nodes = api.get_nodes('blog')
        for node in nodes:
            self.assertEquals(node.type, 'blog')

        nodes = api.get_nodes('board')
        for node in nodes:
            self.assertEquals(node.type, 'board')
Exemplo n.º 13
0
    def test_get_nodes(self):
        api = CSEAPI()

        # Test various node types.
        nodes = api.get_nodes('flow')
        for node in nodes:
            self.assertEquals(node.type, 'flow')

        nodes = api.get_nodes('blog')
        for node in nodes:
            self.assertEquals(node.type, 'blog')

        nodes = api.get_nodes('board')
        for node in nodes:
            self.assertEquals(node.type, 'board')
Exemplo n.º 14
0
def view(request, id):
    api = CSEAPI()
    product = api.get_product(id)

    return render_to_response('product/view.html', dict(product=product), context_instance=RequestContext(request))
Exemplo n.º 15
0
def home(request):
    api = CSEAPI()
    products = api.get_products()

    return render_to_response('page/home.html', dict(products=products), context_instance=RequestContext(request))
Exemplo n.º 16
0
    def test_get_user_by_slug(self):
        api = CSEAPI()

        user = api.get_user_by_slug('users/root')
        self.assertIsInstance(user, User)
        self.assertIsInstance(user.id, int)
Exemplo n.º 17
0
    def test_get_user_by_slug(self):
        api = CSEAPI()

        user = api.get_user_by_slug('users/root')
        self.assertIsInstance(user, User)
        self.assertIsInstance(user.id, int)