Comment 2 for bug 1949884

Revision history for this message
Lukas Märdian (slyon) wrote :

I can confirm these issues and prepared a few reproducer testcases (for test_cli_get_set.py), let's try to get those resolved!

    def test_set_empty_hint_file(self):
        empty_file = os.path.join(self.workdir.name, 'etc', 'netplan', '00-empty.yaml')
        open(empty_file, 'w').close() # touch empty file
        self._set(['ethernets.eth0.dhcp4=true', '--origin-hint=00-empty'])
        print(empty_file, flush=True)
        self.assertTrue(os.path.isfile(empty_file))
        with open(empty_file, 'r') as f:
            self.assertIn('network:\n ethernets:\n eth0:\n dhcp4: true', f.read())

    def test_set_network_null_hint(self):
        not_a_file = os.path.join(self.workdir.name, 'etc', 'netplan', '00-no-exist.yaml')
        self._set(['network=null', '--origin-hint=00-no-exist'])
        self.assertFalse(os.path.isfile(not_a_file))

    def test_set_network_null(self):
        not_a_file = os.path.join(self.workdir.name, 'etc', 'netplan', '00-no-exist.yaml')
        self._set(['network=null'])
        self.assertFalse(os.path.isfile(not_a_file))