Commit 6973523533c7ab7e28da731650325f3e39e99793

Authored by Matheus Fernandes
1 parent c5e39ce7

Initial tests of data_api

Signed-off-by: Matheus Fernandes <matheus.souza.fernandes@gmail.com>
Signed-off-by: Lucas Moura <lucas.mouta128@gmail.com>
colab/plugins/gitlab/data_api.py
... ... @@ -28,7 +28,6 @@ class GitlabDataAPI(ProxyDataAPI):
28 28 if upstream[-1] == '/':
29 29 upstream = upstream[:-1]
30 30  
31   - print u'{}{}?{}'.format(upstream, path, params)
32 31 return u'{}{}?{}'.format(upstream, path, params)
33 32  
34 33 def get_json_data(self, api_url, page, pages=1000):
... ...
colab/plugins/gitlab/tests/test_data_api.py 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +from django.test import TestCase
  2 +from colab.plugins.gitlab.data_api import GitlabDataAPI
  3 +from mock import patch
  4 +
  5 +
  6 +class GitlabDataApiTest(TestCase):
  7 +
  8 + data = {'menu_title': None,
  9 + 'private_token': 'token',
  10 + 'upstream': 'localhost/gitlab/'}
  11 +
  12 + def setUp(self):
  13 + self.api = GitlabDataAPI()
  14 +
  15 + def tearDown(self):
  16 + pass
  17 +
  18 + @patch.dict('django.conf.settings.PROXIED_APPS', gitlab=data)
  19 + def test_resquest_url(self):
  20 + url = self.api.get_request_url('/test/')
  21 + expected = 'localhost/gitlab/test/?private_token=token'
  22 + self.assertEqual(url, expected)
  23 +
  24 + @patch.dict('django.conf.settings.PROXIED_APPS', gitlab=data)
  25 + def test_resquest_url_with_params(self):
  26 + url = self.api.get_request_url('/test/', param='param')
  27 + expected = 'localhost/gitlab/test/?private_token=token&param=param'
  28 + self.assertEqual(url, expected)
... ...