Beispiel #1
0
    def test_make_request_put(self):
        """ expects to use the patch action and returns a status_code """

        api = ('test', 'foo')
        params = {
            'name': 'test',
        }
        args_params = ('2',)

        response = make_request(*args_params, action='PUT', api=api, **params)
        headers = response.headers
        status_code = response.status_code
        url = response.url
        elapsed = response.elapsed
        request = response.request

        logger.debug("request => %s", response)
        logger.debug("request status_code: %s", status_code)
        logger.debug("request => %s", url)
        logger.debug("headers => %s", headers)
        logger.debug("elapsed => %s", elapsed)
        logger.debug("request => %s", request.method)
        
        assert_equal(request.method, 'PATCH')
        assert_equal(type(status_code), int)
        assert_true(headers['Content-Type'] == 'text/html')
        assert_equal(api_url + '/bar/2/', url)
    def tearDown(self):
        """ runs after every test """

        logger.debug("tearDown")
        args_params = (str(self.language_id), )
        api = ('spanglish', 'language')
        response = make_request(*args_params, api=api, action='DELETE', **{})
        status_code = response.status_code
        logger.debug("response status_code: %s", status_code)
Beispiel #3
0
    def test_make_request_with_unknown_action(self):
        """ use an unknown action, expects a dic response with the error """

        api = ('test', 'foo')
        params = {
            'name': 'foo',
        }
        args_params = ('1',)

        response = make_request(*args_params, action='FOO', api=api, **params)
        logger.debug("response: %s", response)

        assert_true(response.get('ERROR', False))
    def setUp(self):
        """ runs before any test """

        logger.debug("setUp")
        language = 'NL'
        params = {'iso1': language}
        api = ('spanglish', 'language')
        response = make_request(api=api, action='POST', **params)
        content = response.json()
        status_code = response.status_code
        logger.debug("response status_code: %s", status_code)
        logger.debug("response content: %s", content)
        if status_code == 201:
            self.language_id = content['id']
        else:
            self.language_id = 0

        logger.debug("language_id created: %d", self.language_id)
Beispiel #5
0
    def setUp(self):
        """ runs before any test """

        logger.debug("setUp")
        self.random_number = random.randint(1,101)
        logger.debug("random_number generated: %s", self.random_number)
        category_name = 'test'.__add__(str(self.random_number))
        params = {'name': category_name}
        api = ('spanglish', 'category')
        response = make_request(api=api, action='POST', **params)
        content = response.json()
        status_code = response.status_code
        logger.debug("response status_code: %s", status_code)
        logger.debug("response content: %s", content)
        if status_code == 201:
            self.category_id = content['id']
        else:
            self.category_id = 0

        logger.debug("category_id created: %d", self.category_id)
Beispiel #6
0
    def test_make_request_get_with_no_args(self):
        """ test the make request method with a get action and no args. """

        api = ('test', 'foo')
        response =  make_request(action='GET', api=api, **{})
        headers = response.headers
        status_code = response.status_code
        url = response.url
        elapsed = response.elapsed
        request = response.request

        logger.debug("request => %s", response)
        logger.debug("request status_code: %s", status_code)
        logger.debug("request => %s", url)
        logger.debug("header => %s", headers)
        logger.debug("elapsed => %s", elapsed)
        logger.debug("request => %s", request.method)
        
        assert_equal(request.method, 'GET')
        assert_equal(type(status_code), int)
        assert_true(headers['Content-Type'] == 'text/html')
        assert_equal(api_url + '/bar/', url)
Beispiel #7
0
    def setUp(self):
        """ runs before any test """

        logger.debug("setUp")

        self.random_number = random.randint(1, 101)
        logger.debug("random_number generated: %s", self.random_number)
        word = 'test'.__add__(str(self.random_number))
        word_en = 'test_en_'.__add__(str(self.random_number))
        category = 'Entertainment'
        language = 'EN'

        params = {
            'word': word,
            'word_en': word_en,
            'category': category,
            'language': language,
        }

        api = ('spanglish', 'word')

        response = make_request(api=api, action='POST', **params)
        status_code = response.status_code

        if status_code == 201:
            content = response.json()
            self.word_id = content['id']

            logger.debug("word_id created: %d", self.word_id)

        else:
            content = response.text
            self.word_id = 1

        logger.debug("response status_code: %s", status_code)
        logger.debug("word response content: %s", content)