Exemple #1
0
    def test_binary_version(self, tmpdir):
        ''''!
        Test the functions __which_current_image and __binary_version
        '''
        content = """#!/bin/sh

        exit 0
        """
        self.__write_file("/tmp/test_firmware", content)
        d = tmpdir.mkdir("valid")
        fh = d.join("input.json")
        fh.write("""
        {
            "01-firmware": {
                "halt-on-failure": false,
                "ignore-result": false,
                "install": {
                    "url": {
                        "source": "file:///tmp/test_firmware"
                    }
                },
                "plugin": "firmware",
                "reboot-on-failure": false,
                "reboot-on-success": false,
                "status": "BOOT",
                "timestamp": "2019-04-25 00:34:10"
            }
        }
        """)
        firmware = Firmware(str(fh))
        current_image = firmware._Firmware__which_current_image()
        assert (current_image != '')
        v = firmware._Firmware__binary_version("foo")
        assert (v == '')
        v = firmware._Firmware__binary_version(current_image)
        assert (v == '')
        with pytest.raises(SystemExit) as pytest_wrapped_e:
            firmware._Firmware__set_default_image('Foo')
        assert pytest_wrapped_e.type == SystemExit
        assert pytest_wrapped_e.value.code == 1

        with pytest.raises(SystemExit) as pytest_wrapped_e:
            firmware._Firmware__set_next_boot_image('Foo')
        assert pytest_wrapped_e.type == SystemExit
        assert pytest_wrapped_e.value.code == 1