Beispiel #1
0
 def test_dict_params_with_exposed_endpoints_data(self):
     params = {
         "application": "application",
         "exposed-endpoints": {
             "": {
                 "to-spaces": ["alpha"],
                 "to-cidrs": ["10.0.0.0/24"]
             },
             "foo": {
                 "to-spaces": ["alien"],
                 "to-cidrs": ["0.0.0.0/0", "::/0"]
             }
         }
     }
     change = ExposeChange(1, [], params=params)
     self.assertEqual(
         {
             "change_id": 1,
             "requires": [],
             "application": "application",
             "exposed_endpoints": {
                 "": {
                     "to-spaces": ["alpha"],
                     "to-cidrs": ["10.0.0.0/24"]
                 },
                 "foo": {
                     "to-spaces": ["alien"],
                     "to-cidrs": ["0.0.0.0/0", "::/0"]
                 }
             }
         }, change.__dict__)
Beispiel #2
0
 def test_dict_params_missing_data(self):
     change = ExposeChange(1, [], params={})
     self.assertEqual({
         "change_id": 1,
         "requires": [],
         "application": None
     }, change.__dict__)
Beispiel #3
0
 def test_dict_params(self):
     change = ExposeChange(1, [], params={"application": "application"})
     self.assertEqual(
         {
             "change_id": 1,
             "requires": [],
             "application": "application"
         }, change.__dict__)
Beispiel #4
0
 def test_list_params(self):
     change = ExposeChange(1, [], params=["application"])
     self.assertEqual(
         {
             "change_id": 1,
             "requires": [],
             "application": "application",
             "exposed_endpoints": None
         }, change.__dict__)
Beispiel #5
0
    async def test_run(self, event_loop):
        change = ExposeChange(1, [], params={"application": "application"})

        app = mock.Mock()
        app.expose = base.AsyncMock(return_value=None)

        model = MockModel({"application1": app})

        context = mock.Mock()
        context.resolve = mock.Mock(side_effect=['application1'])
        context.model = model

        result = await change.run(context)
        assert result is None

        model.applications["application1"].expose.assert_called_once()
Beispiel #6
0
    async def test_run(self, event_loop):
        params = {
            "application": "application",
            "exposed-endpoints": {
                "": {
                    "to-spaces": ["alpha"],
                    "to-cidrs": ["10.0.0.0/24"]
                },
                "foo": {
                    "to-spaces": ["alien"],
                    "to-cidrs": ["0.0.0.0/0", "::/0"]
                }
            }
        }
        change = ExposeChange(1, [], params=params)

        app = mock.Mock()
        app.expose = base.AsyncMock(return_value=None)

        model = MockModel({"application1": app})

        context = mock.Mock()
        context.resolve = mock.Mock(side_effect=['application1'])
        context.model = model

        result = await change.run(context)
        assert result is None

        model.applications["application1"].expose.assert_called_once()
        model.applications["application1"].expose.assert_called_with({
            "": {
                "to-spaces": ["alpha"],
                "to-cidrs": ["10.0.0.0/24"]
            },
            "foo": {
                "to-spaces": ["alien"],
                "to-cidrs": ["0.0.0.0/0", "::/0"]
            }
        })
Beispiel #7
0
 def test_method(self):
     self.assertEqual("expose", ExposeChange.method())