コード例 #1
0
    def test_wrong_host(self, get_host, get_channel_id, list_channels):
        get_host.return_value = None

        with self.assertRaises(koji.GenericError):
            kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        self.assertEqual(len(self.updates), 0)
コード例 #2
0
    def test_wrong_host(self, get_host, get_channel_id, list_channels):
        get_host.return_value = None

        with self.assertRaises(koji.GenericError):
            kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        self.assertEqual(len(self.updates), 0)
コード例 #3
0
    def test_wrong_channel(self, get_host, get_channel_id, list_channels):
        get_host.return_value = {'id': 123, 'name': 'hostname'}
        get_channel_id.return_value = None
        list_channels.return_value = [{'id': 234, 'name': 'channelname'}]

        with self.assertRaises(koji.GenericError):
            kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        get_channel_id.assert_called_once_with('channelname')
        self.assertEqual(len(self.updates), 0)
コード例 #4
0
    def test_wrong_channel(self, get_host, get_channel_id, list_channels):
        get_host.return_value = {'id': 123, 'name': 'hostname'}
        get_channel_id.return_value = None
        list_channels.return_value = [{'id': 234, 'name': 'channelname'}]

        with self.assertRaises(koji.GenericError):
            kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        get_channel_id.assert_called_once_with('channelname')
        self.assertEqual(len(self.updates), 0)
コード例 #5
0
    def test_missing_record(self, get_host, get_channel_id, list_channels):
        get_host.return_value = {'id': 123, 'name': 'hostname'}
        get_channel_id.return_value = 234
        list_channels.return_value = []

        with self.assertRaises(koji.GenericError):
            kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        get_channel_id.assert_called_once_with('channelname')
        list_channels.assert_called_once_with(123)
        self.assertEqual(len(self.updates), 0)
コード例 #6
0
    def test_missing_record(self, get_host, get_channel_id, list_channels):
        get_host.return_value = {'id': 123, 'name': 'hostname'}
        get_channel_id.return_value = 234
        list_channels.return_value = []

        with self.assertRaises(koji.GenericError):
            kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        get_channel_id.assert_called_once_with('channelname')
        list_channels.assert_called_once_with(123)
        self.assertEqual(len(self.updates), 0)
コード例 #7
0
    def test_valid(self, get_host, get_channel_id, list_channels):
        get_host.return_value = {'id': 123, 'name': 'hostname'}
        get_channel_id.return_value = 234
        list_channels.return_value = [{'id': 234, 'name': 'channelname'}]

        kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        get_channel_id.assert_called_once_with('channelname')
        list_channels.assert_called_once_with(123)

        self.assertEqual(len(self.updates), 1)
        update = self.updates[0]
        values = {
            'host_id': 123,
            'channel_id': 234,
        }
        clauses = [
            'host_id = %(host_id)i AND channel_id = %(channel_id)i',
            'active = TRUE',
        ]
        self.assertEqual(update.table, 'host_channels')
        self.assertEqual(update.values, values)
        self.assertEqual(update.clauses, clauses)
コード例 #8
0
    def test_valid(self, get_host, get_channel_id, list_channels):
        get_host.return_value = {'id': 123, 'name': 'hostname'}
        get_channel_id.return_value = 234
        list_channels.return_value = [{'id': 234, 'name': 'channelname'}]

        kojihub.remove_host_from_channel('hostname', 'channelname')

        get_host.assert_called_once_with('hostname')
        get_channel_id.assert_called_once_with('channelname')
        list_channels.assert_called_once_with(123)

        self.assertEqual(len(self.updates), 1)
        update = self.updates[0]
        values = {
            'host_id': 123,
            'channel_id': 234,
        }
        clauses = [
            'host_id = %(host_id)i AND channel_id = %(channel_id)i',
            'active = TRUE',
        ]
        self.assertEqual(update.table, 'host_channels')
        self.assertEqual(update.values, values)
        self.assertEqual(update.clauses, clauses)