def test_parameter_empty(self, get_mock):
        # type: (Mock) -> None
        get_mock.return_value = Response(True, '[]', 200)

        request = ProductsResource(config=self.config)
        result = request.list_parameters('PRD-000-000-000')
        assert get_mock.call_count == 1
        url = 'http://localhost:8080/public/v1/products/PRD-000-000-000/parameters/'
        get_mock.assert_has_calls([
            call(headers={
                'Content-Type': 'application/json',
                'Authorization': 'ApiKey XXXX:YYYYY'
            },
                 timeout=300,
                 url=url)
        ])
        self.assertEqual(result, [], msg=None)
    def test_parameters_request_ok(self, get_mock):
        # type: (Mock) -> None
        get_mock.side_effect = [
            Response(True, '[' + get_parameters_contents + ']', 200),
            Response(True, get_parameters_contents, 200)
        ]

        request = ProductsResource(config=self.config)
        result = request.list_parameters('PRD-075-401-854')
        assert get_mock.call_count == 1
        self.assertEqual(len(result), 1, msg=None)

        get_mock.assert_has_calls([
            call(headers={
                'Content-Type': 'application/json',
                'Authorization': 'ApiKey XXXX:YYYYY'
            },
                 timeout=300,
                 url=('http://localhost:8080/public/v1/'
                      'products/PRD-075-401-854/parameters/'))
        ])
Exemple #3
0
 def list_parameters(self, product_id):
     product = ProductsResource(config=self.configuration)
     return product.list_parameters(product_id)