def setUp(self):
     self.asset_uid = None
     self.stack = contentstack.Stack(config.api_key,
                                     config.delivery_token,
                                     config.environment,
                                     host=config.host)
     self.asset_query = self.stack.asset_query()
 def test_10_get_headers(self):
     stack = contentstack.Stack(config.api_key, config.delivery_token,
                                config.environment)
     self.assertEqual(True, 'api_key' in stack.headers)
     self.assertEqual(True, 'access_token' in stack.get_headers)
     self.assertEqual(True, 'environment' in stack.get_headers)
     self.assertEqual(3, stack.get_headers.__len__())
예제 #3
0
 def setUp(self):
     self.api_key = credentials.keys['api_key']
     self.delivery_token = credentials.keys['delivery_token']
     self.environment = credentials.keys['environment']
     self.stack = contentstack.Stack(self.api_key, self.delivery_token,
                                     self.environment)
     self.asset_query = self.stack.asset_query()
 def test_011_setting_timeout(self):
     excepted = 13  # setting a custom timeout
     self.stack = contentstack.Stack(config.api_key,
                                     config.delivery_token,
                                     config.environment,
                                     host=config.host,
                                     timeout=excepted)
     self.assertEqual(excepted, self.stack.timeout)
예제 #5
0
 def setUp(self):
     self.stack = contentstack.Stack(config.api_key,
                                     config.delivery_token,
                                     config.environment,
                                     host=config.host)
     self.query = self.stack.content_type('room').query()
     self.query1 = self.stack.content_type('product').query()
     self.query2 = self.stack.content_type('app_theme').query()
     self.query3 = self.stack.content_type('product').query()
예제 #6
0
 def test_fail_delivery_token(self):
     try:
         stack = contentstack.Stack(self.api_key, '', self.environment)
         self.assertEqual(None, stack.delivery_token)
     except PermissionError as e:
         if hasattr(e, 'message'):
             self.assertEqual(
                 "'You are not permitted to the stack without valid Delivery Token'",
                 e.args[0])
예제 #7
0
def initStack():
    '''
    Bug. Seems I have to initialize the stack every time.
    Otherwise results are not to be trusted.
    '''
    stack = contentstack.Stack(api_key=api_key,
                               access_token=delivery_token,
                               environment=environment,
                               config=config)
    return stack
예제 #8
0
 def test_fail(self):
     try:
         stack_local = contentstack.Stack('', self.delivery_token,
                                          self.environment)
         self.assertEqual(None, stack_local.api_key)
     except PermissionError as e:
         if hasattr(e, 'message'):
             self.assertEqual(
                 "'You are not permitted to the stack without valid Api Key'",
                 e.args[0])
 def test_05_permission_error_environment(self):
     try:
         stack = contentstack.Stack(config.api_key, config.delivery_token,
                                    '')
         self.assertEqual(None, stack.delivery_token)
     except PermissionError as e:
         if hasattr(e, 'message'):
             self.assertEqual(
                 "You are not permitted to the stack without valid Environment",
                 e.args[0])
예제 #10
0
 def test_12_entry_include_reference_github_issue(self):
     stack_for_products = contentstack.Stack("blt02f7b45378b008ee",
                                             "cs5b69faf35efdebd91d08bcf4",
                                             "production")
     github_entry = stack_for_products.content_type('product').entry(
         "blte63b2ff6f6414d8e").include_reference(["categories", "brand"])
     response = github_entry.fetch()
     print(response)
     categories = response['entry']['categories']
     self.assertEqual(2, len(categories))
예제 #11
0
 def setUp(self):
     config_logging(logging.WARNING)
     self.api_key = credentials.keys['api_key']
     self.delivery_token = credentials.keys['delivery_token']
     self.environment = credentials.keys['environment']
     stack = contentstack.Stack(self.api_key, self.delivery_token,
                                self.environment)
     self.query = stack.content_type('room').query()
     self.query1 = stack.content_type('product').query()
     self.query2 = stack.content_type('app_theme').query()
     self.query3 = stack.content_type('product').query()
 def test_12_setting_timeout_failure(self):
     try:
         excepted = 0.01  # setting a custom timeout
         self.stack = contentstack.Stack(config.api_key,
                                         config.delivery_token,
                                         config.environment,
                                         host=config.host,
                                         timeout=excepted)
         # self.assertEqual(1, self.stack.timeout)
         result = self.stack.asset_query().find()
     except TimeoutError:
         self.assertEqual('Timeout expired.', TimeoutError.__doc__)
 def test_013_setting_retry_strategy_unit(self):
     from urllib3 import Retry
     self.stack = contentstack.Stack(config.api_key,
                                     config.delivery_token,
                                     config.environment,
                                     host=config.host,
                                     retry_strategy=Retry(
                                         total=3,
                                         backoff_factor=1,
                                         status_forcelist=[408]))
     self.assertEqual(1, self.stack.retry_strategy.backoff_factor)
     self.assertEqual(3, self.stack.retry_strategy.total)
     self.assertEqual([408], self.stack.retry_strategy.status_forcelist)
예제 #14
0
 def setUp(self):
     self.stack = contentstack.Stack(config.api_key,
                                     config.delivery_token,
                                     config.environment,
                                     host=config.host)
예제 #15
0
 def test_stack_region(self):
     stack_region = contentstack.Stack(self.api_key,
                                       self.delivery_token,
                                       self.environment,
                                       region=ContentstackRegion.EU)
     self.assertEqual('eu-cdn.contentstack.com', stack_region.host)
예제 #16
0
 def test_09_get_environment(self):
     stack = contentstack.Stack(config.api_key, config.delivery_token,
                                config.environment)
     self.assertEqual(config.environment, stack.get_environment)
예제 #17
0
import logging
import unittest

from HtmlTestRunner import HTMLTestRunner

import contentstack
from contentstack.stack import ContentstackRegion
from tests import credentials

api_key = credentials.keys['api_key']
delivery_token = credentials.keys['delivery_token']
environment = credentials.keys['environment']
stack_instance = contentstack.Stack(api_key, delivery_token, environment)


class TestStack(unittest.TestCase):
    def setUp(self):
        self.api_key = credentials.keys['api_key']
        self.delivery_token = credentials.keys['delivery_token']
        self.environment = credentials.keys['environment']
        self.stack = contentstack.Stack(self.api_key, self.delivery_token,
                                        self.environment)

    def test_stack_credentials(self):
        self.assertEqual(self.environment, stack_instance.environment)
        self.assertEqual(self.delivery_token, stack_instance.delivery_token)
        self.assertEqual(self.api_key, stack_instance.api_key)

    def test_stack_region(self):
        stack_region = contentstack.Stack(self.api_key,
                                          self.delivery_token,
예제 #18
0
import logging
import unittest

import config
import contentstack
from contentstack.stack import ContentstackRegion

stack_instance = contentstack.Stack(config.api_key,
                                    config.delivery_token,
                                    config.environment,
                                    host=config.host)


class TestStack(unittest.TestCase):
    def setUp(self):
        self.stack = contentstack.Stack(config.api_key,
                                        config.delivery_token,
                                        config.environment,
                                        host=config.host)

    def test_01_stack_credentials(self):
        self.assertEqual(config.environment, stack_instance.environment)
        self.assertEqual(config.delivery_token, stack_instance.delivery_token)
        self.assertEqual(config.api_key, stack_instance.api_key)
        self.assertEqual(config.host, stack_instance.host)

    def test_02_stack_region(self):
        stack_region = contentstack.Stack(config.api_key,
                                          config.delivery_token,
                                          config.environment,
                                          region=ContentstackRegion.EU)