Open Kilda Java Documentation
test_config.py
Go to the documentation of this file.
1 # Copyright 2017 Telstra Open Source
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 
16 from topologylistener import db
17 from topologylistener import messageclasses
18 from topologylistener.tests import share
19 
20 
22  data = payload.copy()
23  data['clazz'] = (
24  'org.openkilda.messaging.command.system.FeatureToggleRequest')
25  message = share.command(data)
26  return messageclasses.MessageItem(message).handle()
27 
28 
30  tx.run('MATCH (c:config) DETACH DELETE c')
31 
32 
34  def setUp(self):
35  super(TestConfig, self).setUp()
36  with share.env.neo4j_connect.begin() as tx:
38  messageclasses.read_config()
39 
40  def test_update(self):
41  features_request = share.feature_toggle_request(**{
42  messageclasses.features_status_app_to_transport_map[
43  messageclasses.FEATURE_REROUTE_ON_ISL_DISCOVERY]: False})
44  self.assertTrue(share.feed_message(share.command(features_request)))
45 
46  with share.env.neo4j_connect.begin() as tx:
47  cursor = tx.run(
48  'MATCH (c:config {name: "config"}) RETURN c LIMIT 2')
49  db_config = db.fetch_one(cursor)['c']
50  self.assertEqual(
51  False,
52  db_config[
53  messageclasses.features_status_app_to_transport_map[
54  messageclasses.FEATURE_REROUTE_ON_ISL_DISCOVERY]])
55 
56  def test_existing(self):
57  with share.env.neo4j_connect.begin() as tx:
58  q = 'CREATE (c:config) SET c = $data'
59  p = {
60  'data': {
61  'name': 'config',
62  'reflow_on_switch_activation': False,
63  'unpush_flow': False,
64  'sync_rules': False,
65  'push_flow': False,
66  'delete_flow': False,
67  'create_flow': False,
68  'update_flow': False}}
69  tx.run(q, p)
70 
71  messageclasses.read_config()
72  self.assertFalse(
73  messageclasses.features_status[
74  messageclasses.FEATURE_REROUTE_ON_ISL_DISCOVERY])