Esempio n. 1
0
    def test_config_insert_for_host_for_key(self, objects):

        inst = objects.return_value
        inst.first.return_value = self.host

        hostname = "example.com"
        config = [
            {
                "patterns": [
                    "http:\/\/example.com\/.*.php"
                ],
                "actions": ["follow", "noindex"]
            }
        ]

        push_configuration_for_host(hostname, config, "crawlConfig")
        self.assertIn("noindex",
                      self.host.config['crawlConfig'][0]["actions"])
Esempio n. 2
0
    def test_config_insert_for_host(self, objects):

        inst = objects.return_value
        inst.first.return_value = self.host

        config = {
            "exports": {
                "nimbusview": {
                    "push_api_url": "http://test.api:2323"
                }
            }
        }

        push_configuration_for_host("example.com", config)

        self.assertEqual(len(self.host.config), 1)
        self.assertIn("exports", self.host.config)
        self.assertEqual(
            self.host.config['exports']['nimbusview']['push_api_url'],
            "http://test.api:2323"
        )
Esempio n. 3
0
    def test_config_insert_for_host_for_nested_key_not_existing(self, objects):

        host = self.host
        config = {
            "exports": {
            }
        }
        host.config = config
        host.save()

        inst = objects.return_value
        inst.first.return_value = host

        hostname = "example.com"
        config = "http://test2.api:2323"

        push_configuration_for_host(hostname, config,
                                    "exports.nimbusview.push_api_url")

        self.assertEqual(host.config['exports']['nimbusview']['push_api_url'],
                         config)