def test_client_with_application_version_only_does_not_include_integration_in_header( self): client = Client('cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False, application_version='0.1.0') header = client._contentful_user_agent() self.assertFalse('app /0.1.0;' in header)
def test_client_with_integration_name_only_headers(self): client = Client('cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False, integration_name='foobar') header = client._contentful_user_agent() self.assertTrue('integration foobar;' in header) self.assertFalse('integration foobar/;' in header)
def test_client_with_application_headers(self): client = Client('cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False, application_name='foobar', application_version='0.1.0') header = client._contentful_user_agent() self.assertTrue('app foobar/0.1.0;' in header)
def test_client_default_contentful_user_agent_headers(self): client = Client('cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False) from contentful import __version__ import platform expected = [ 'sdk contentful.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()) ] header = client._contentful_user_agent() for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header)) self.assertTrue('integration' not in header) self.assertTrue('app' not in header)
def test_client_with_all_headers(self): client = Client('cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False, application_name='foobar_app', application_version='1.1.0', integration_name='foobar integ', integration_version='0.1.0') from contentful import __version__ import platform expected = [ 'sdk contentful.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()), 'app foobar_app/1.1.0;', 'integration foobar integ/0.1.0;' ] header = client._contentful_user_agent() for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header))