1from tests.package.test_python import TestPythonPackageBase
2import os
3
4
5class TestPythonPahoMQTT(TestPythonPackageBase):
6    __test__ = True
7    config = TestPythonPackageBase.config + \
8        """
9        BR2_PACKAGE_MOSQUITTO=y
10        BR2_PACKAGE_MOSQUITTO_BROKER=y
11        BR2_PACKAGE_PYTHON3=y
12        BR2_PACKAGE_PYTHON_PAHO_MQTT=y
13        """
14    sample_scripts = ["tests/package/sample_python_paho_mqtt.py"]
15
16    def test_run(self):
17        self.login()
18        self.check_sample_scripts_exist()
19
20        cmd = "%s %s" % (self.interpreter, os.path.basename(self.sample_scripts[0]))
21        output, exit_code = self.emulator.run(cmd)
22        self.assertEqual(exit_code, 0)
23        self.assertEqual(output[0], "Hello, World!")
24