Exemple #1
0
    def test_get_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.side_effect = dss_error.Error(
            'some error')

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

        mock_dss_client.return_value.get_domain.assert_called_once_with(
            'a domain')
Exemple #2
0
    def test_get(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')
        ])

        value = handler.get('a domain', 'name')

        assert value == 'value'
Exemple #3
0
    def test_get_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'
        ]
        mock_dss_client.return_value.get_domain.return_value = OrderedDict([
            ('name', 'value')
        ])

        value = handler.get('some domain', 'a name')

        assert value is None

        mock_dss_client.return_value.get_domain.assert_not_called()
        mock_dss_client.return_value.get_domains.assert_called_once()