~mpontillo/maas/subnet-dhcp-dns-settings--bug-1600720

« back to all changes in this revision

Viewing changes to src/provisioningserver/dhcp/tests/test_config.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from provisioningserver.boot import BootMethodRegistry
17
17
from provisioningserver.dhcp import config
18
18
from provisioningserver.dhcp.testing.config import (
 
19
    make_dhcp_snippets,
19
20
    make_failover_peer_config,
20
21
    make_host,
21
22
    make_shared_network,
81
82
        'failover_peers': failover_peers,
82
83
        'shared_networks': shared_networks,
83
84
        'hosts': hosts,
 
85
        'global_dhcp_snippets': make_dhcp_snippets(),
84
86
        }
85
87
 
86
88
 
215
217
                for host in hosts
216
218
            ]))
217
219
 
 
220
    def test__renders_global_dhcp_snippets(self):
 
221
        params = make_sample_params()
 
222
        config_output = config.get_config('dhcpd.conf.template', **params)
 
223
        self.assertThat(
 
224
            config_output,
 
225
            ContainsAll([
 
226
                dhcp_snippet['value']
 
227
                for dhcp_snippet in params['global_dhcp_snippets']
 
228
            ]))
 
229
 
 
230
    def test__renders_subnet_dhcp_snippets(self):
 
231
        params = make_sample_params()
 
232
        config_output = config.get_config('dhcpd.conf.template', **params)
 
233
        for shared_network in params['shared_networks']:
 
234
            for subnet in shared_network['subnets']:
 
235
                self.assertThat(
 
236
                    config_output,
 
237
                    ContainsAll([
 
238
                        dhcp_snippet['value']
 
239
                        for dhcp_snippet in subnet['dhcp_snippets']
 
240
                    ]))
 
241
 
 
242
    def test__renders_node_dhcp_snippets(self):
 
243
        params = make_sample_params()
 
244
        config_output = config.get_config('dhcpd.conf.template', **params)
 
245
        for host in params['hosts']:
 
246
            self.assertThat(
 
247
                config_output,
 
248
                ContainsAll([
 
249
                    dhcp_snippet['value']
 
250
                    for dhcp_snippet in host['dhcp_snippets']
 
251
                ]))
 
252
 
218
253
 
219
254
class TestComposeConditionalBootloader(PservTestCase):
220
255
    """Tests for `compose_conditional_bootloader`."""