self.assertEqual(len(result), 2) self.assertEqual(result[0]["url"], "http://exemple.mandriva.com") def test_get_repositories_already_installed(self): result = self.client.call('get_repositories', ['module3']) self.assertEqual(len(result), 0) def test_get_sections(self): result = self.client.call('get_sections') self.assertEqual(result, [{'slug': 'test', 'name': 'Test'}]) def test_get_section(self): result = self.client.call('get_section', 'test') self.assertEqual(len(result[0]["modules"]), 1) self.assertEqual(result[0]["modules"][0]["slug"], "module1") self.assertEqual(result[0]["slug"], "other") if __name__ == '__main__': modules = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'basic_modules') config = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'agent.ini') cleanup_tests() setup_modules(modules) process = run_agent(config) run_tests(TestBasics, process) stop_agent(process) cleanup_tests()
# 'slug': u'module1'}] # Fill the configuration config = {"module1_option1": "bar", "module1_option2": "on"} # Validate the configuration (config_err, config_result) = self.client.call('valid_config', ['module1'], config) self.assertFalse(config_err) module1_config = config_result[0] self.assertEqual(module1_config[0]["default"], "bar") self.assertEqual(module1_config[1]["default"], "on") def test_required_field(self): config = {"module2_option2": "foo"} # Validate the configuration (config_err, config_result) = self.client.call('valid_config', ['module2'], config) self.assertTrue(config_err) module2_config = config_result[0] self.assertIn("error", module2_config[0]) self.assertNotIn("error", module2_config[1]) if __name__ == '__main__': modules = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config_modules') config = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'agent.ini') cleanup_tests() setup_modules(modules) process = run_agent(config) run_tests(TestModuleConfiguration, process) stop_agent(process) cleanup_tests()
def test_get_repositories(self): result = self.client.call('get_repositories', ['module1', 'module2']) self.assertEqual(len(result), 2) self.assertEqual(result[0]["url"], "http://exemple.mandriva.com") def test_get_repositories_already_installed(self): result = self.client.call('get_repositories', ['module3']) self.assertEqual(len(result), 0) def test_get_sections(self): result = self.client.call('get_sections') self.assertEqual(result, [{'slug': 'test', 'name': 'Test'}]) def test_get_section(self): result = self.client.call('get_section', 'test') self.assertEqual(len(result[0]["modules"]), 1) self.assertEqual(result[0]["modules"][0]["slug"], "module1") self.assertEqual(result[0]["slug"], "other") if __name__ == '__main__': modules = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'basic_modules') config = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'agent.ini') cleanup_tests() setup_modules(modules) process = run_agent(config) run_tests(TestBasics, process) stop_agent(process) cleanup_tests()
config_result = self.client.call('valid_config', ['module1'], {"module1_custom": "bar"}) self.assertTrue(config_result[0]["errors"]) module1_config = config_result[0]["config"] self.assertEqual(module1_config[4]["error"], "Value is not foo") config_result = self.client.call('valid_config', ['module1'], {"module1_custom": "foo"}) self.assertFalse(config_result[0]["errors"]) module1_config = config_result[0]["config"] self.assertNotIn("error", module1_config[4]) def test_multi_required(self): config_result = self.client.call('valid_config', ['module2'], {"module2_field1_0_field": ""}) self.assertTrue(config_result[0]["errors"]) module2_config = config_result[0]["config"] self.assertEqual(module2_config[0]["error"], "This field can't be empty.") config_result = self.client.call('valid_config', ['module2'], {"module2_field1_0_field": "foo"}) self.assertFalse(config_result[0]["errors"]) module2_config = config_result[0]["config"] self.assertNotIn("error", module2_config[0]) if __name__ == '__main__': modules = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'validation_modules') config = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'agent.ini') cleanup_tests() setup_modules(modules) process = run_agent(config) run_tests(TestConfigValidation, process) stop_agent(process) cleanup_tests()