示例#1
0
    def test_get_channels(self):
        self.set_channels_get_success_response()

        data = get_channels(self.mock_session, 'package.name')

        expected = {
            'success': True,
            'errors': [],
            'data': self.channels_data,
        }
        self.assertEqual(data, expected)
示例#2
0
    def test_get_channels_with_error_response(self):
        error_msg = 'some error'
        self.set_channels_get_error_response(error_msg)

        data = get_channels(self.mock_session, 'package.name')

        expected = {
            'success': False,
            'errors': [error_msg],
            'data': None,
        }
        self.assertEqual(data, expected)
示例#3
0
 def test_get_channels_uses_environment_variables(self):
     with patch('snapcraft.storeapi.common.os.environ',
                {'UBUNTU_STORE_API_ROOT_URL': 'http://example.com'}):
         get_channels(self.mock_session, 'package.name')
     self.mock_get.assert_called_once_with(
         'http://example.com/package-channels/package.name/')