Esempio n. 1
0
 def test_render_config_announce_good(self, mock_announce):
     formatted_json = json.loads(tools.exa_raw('announce_g'))
     edit_rib.render_config(formatted_json, self.transport)
     with open(tools.add_location('examples/rendered_announce.txt'),
               'U') as f:
         rendered_announce = f.read()
     mock_announce.assert_called_with(rendered_announce, self.transport)
Esempio n. 2
0
 def test_render_config_normal_model_missing_value(self, mock_announce):
     formatted_json = json.loads(tools.exa_raw('invalid_n_model'))
     edit_rib.rib_announce = mock_announce
     with self.assertRaises(KeyError):
         edit_rib.render_config(formatted_json, self.transport)
     self.assertIn('Not a valid update message type\n',
                   tools.check_errorlog()[0])
     self.assertFalse(mock_announce.called)
Esempio n. 3
0
 def test_render_config_withdraw_good(self, mock_withdraw):
     withdraw_prefixes = [
         '1.1.1.8/32', '1.1.1.5/32', '1.1.1.7/32', '1.1.1.9/32',
         '1.1.1.2/32', '1.1.1.1/32', '1.1.1.6/32', '1.1.1.3/32',
         '1.1.1.10/32', '1.1.1.4/32'
     ]
     formatted_json = json.loads(tools.exa_raw('withdraw_g'))
     edit_rib.render_config(formatted_json, self.transport)
     mock_withdraw.assert_called_with(withdraw_prefixes, self.transport)
Esempio n. 4
0
 def test_rib_5announce_EOR(self):
     with open(tools.add_location('examples/exa/exa-eor.json')) as f:
         exa_announce_eor = f.read()
     edit_rib.render_config(json.loads(exa_announce_eor),
                            edit_rib.transport)
     self.assertIn('EOR message\n', tools.check_debuglog()[0])
Esempio n. 5
0
 def test_rib_4withdraw_json(self):
     with open(tools.add_location(
             'examples/integration/exa-withdraw.json')) as f:
         exa_withdraw = f.read()
     edit_rib.render_config(json.loads(exa_withdraw), edit_rib.transport)
     self.assertIn('| WITHDRAW | OK', tools.check_debuglog()[0])
Esempio n. 6
0
 def test_rib_3announce_json(self):
     with open(tools.add_location(
             'examples/integration/exa-announce.json')) as f:
         exa_announce = f.read()
     edit_rib.render_config(json.loads(exa_announce), edit_rib.transport)
     self.assertIn('| ANNOUNCE | OK', tools.check_debuglog()[0])
Esempio n. 7
0
 def test_render_config_normal_model_eor(self, mock_announce):
     formatted_json = json.loads(tools.exa_raw('announce_eor'))
     #edit_rib.rib_announce = mock_announce
     edit_rib.render_config(formatted_json, self.transport)
     self.assertIn('EOR message\n', tools.check_debuglog()[0])
     self.assertFalse(mock_announce.called)
Esempio n. 8
0
 def test_render_config_prefixes_all_filtered_announce(self, mock_announce):
     edit_rib.FILEPATH = tools.add_location(
         'examples/filter/filter-all.txt')
     formatted_json = json.loads(tools.exa_raw('announce_g'))
     edit_rib.render_config(formatted_json, self.transport)
     mock_announce.assert_not_called()
Esempio n. 9
0
 def test_filter_empty(self, mock_withdraw, mock_filter):
     # The Setup configures us to have an empty filter file
     formatted_json = json.loads(tools.exa_raw('withdraw_g'))
     edit_rib.render_config(formatted_json, self.transport)
     mock_filter.assert_not_called()