Exemplo n.º 1
0
    def test_delete_non_existing_domain(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.return_value = [
            'a domain', 'b domain', 'c domain'
        ]

        handler.delete('not domain', 'no name')

        mock_dss_client.return_value.get_domains.assert_called_once()
        mock_dss_client.return_value.get_domain.assert_not_called()
        mock_dss_client.return_value.delete.assert_not_called()
Exemplo n.º 2
0
    def test_delete_non_existing_name(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.return_value = [
            'a domain', 'b domain', 'c domain'
        ]

        mock_dss_client.return_value.get_domain.return_value = OrderedDict([
            ('name', 'value')
        ])

        handler.delete('a domain', 'a name')

        mock_dss_client.return_value.get_domain.assert_called_once_with(
            'a domain')
        mock_dss_client.return_value.delete.assert_not_called()
Exemplo n.º 3
0
    def test_delete_dss_fails(self, mock_logging, mock_dss_client):
        handler = CMDSSHandler(uri='test_uri')

        mock_dss_client.return_value.get_domains.return_value = [
            'a domain', 'b domain', 'c domain'
        ]

        mock_dss_client.return_value.get_domain.return_value = OrderedDict([
            ('name', 'value')
        ])

        mock_dss_client.return_value.delete.side_effect = dss_error.Error(
            'some error')

        with self.assertRaises(CMError) as context:
            handler.delete('a domain', 'name')

        mock_dss_client.return_value.delete.assert_called_once_with(
            'a domain', 'name')