@@ -39,26 +39,15 @@ def test_client(self):
3939 def test_functions (self ):
4040
4141 self .assertEqual ("Yes I'm here :)" , self .myclient .check_connection ())
42- try :
43- self .assertEqual (list (), self .myclient .get_policies_list ())
44- except Exception as e :
45- print (e )
46- try :
47- self .assertEqual (["test" ], self .myclient .get_policies_list ())
48- except Exception as test :
49- print (test )
50- try :
51- self .assertEqual (dict (), self .myclient .get_policies_info ())
52- except Exception as rr :
53- print (rr )
54- try :
55- my_dict = {'test' : {'path' : [
56- 'http://localhost:8181/v1/data/play' ], 'rules' : ['http://localhost:8181/v1/data/play/hello' ]}}
57-
58- self .assertEqual (my_dict , self .myclient .get_policies_info ())
59- except Exception as testing :
60- print (testing )
61-
42+ self .assertEqual (list (), self .myclient .get_policies_list ())
43+
44+ self .assertEqual (dict (), self .myclient .get_policies_info ())
45+
46+ # _dict = {'test': {'path': [
47+ # 'http://localhost:8181/v1/data/play'], 'rules': ['http://localhost:8181/v1/data/play/hello']}}
48+
49+ # self.assertEqual(_dict, self.myclient.get_policies_info())
50+
6251 new_policy = '''
6352 package play
6453
@@ -72,15 +61,11 @@ def test_functions(self):
7261 self .assertEqual (
7362 True , self .myclient .update_opa_policy_fromstring (new_policy , "test" ))
7463
75- # self.assertEqual(False, self.myclient.update_opa_policy_fromfile(
76- # "/home/root/Documents/OPA-python-client/opa_client/test/test.txt", "test"))
77-
78- # self.assertEqual(self.myclient.update_opa_policy_fromurl())
7964 self .assertEqual (["test" ], self .myclient .get_policies_list ())
80- my_dict = {'test' : {'path' : ['http://localhost:8181/v1/data/play' ],
65+ _dict = {'test' : {'path' : ['http://localhost:8181/v1/data/play' ],
8166 'rules' : ['http://localhost:8181/v1/data/play/hello' ]}}
8267
83- self .assertEqual (my_dict , self .myclient .get_policies_info ())
68+ self .assertEqual (_dict , self .myclient .get_policies_info ())
8469
8570 my_policy_list = [
8671 {"resource" : "/api/someapi" , "identity" : "your_identity" , "method" : "PUT" },
@@ -90,36 +75,14 @@ def test_functions(self):
9075 self .assertTrue (True , self .myclient .update_or_create_opa_data (
9176 my_policy_list , 'exampledata/accesses' ))
9277 value = {'result' : {'hello' : False }}
93- try :
94- self .assertEqual (dict (), self .myclient .get_opa_raw_data ("play" ))
95- except Exception as err :
96- print ("not right one" , err )
97- try :
98- self .assertEqual (
99- value , self .myclient .get_opa_raw_data ("hello" ))
100- except Exception as errr :
101- print (errr )
102-
78+
10379 self .assertEqual (True , self .myclient .opa_policy_to_file ("test" ))
104-
105- try :
106- self .assertEqual (dict (), self .myclient .get_opa_raw_data ("play" ))
107- except Exception as er :
108- print ("not right" , er )
109- try :
110- self .assertEqual (value , self .myclient .get_opa_raw_data ("play" ))
111- except Exception as identifier :
112- print (identifier )
113-
114- # TODO
115- # self.assertEqual("sad", self.myclient.get_opa_policy("test"))
116-
80+
81+ self .assertEqual (value , self .myclient .get_opa_raw_data ("play" ))
82+
11783 self .assertTrue (True , self .myclient .delete_opa_policy ("test" ))
11884 with self .assertRaises (DeletePolicyError ):
11985 self .myclient .delete_opa_policy ("test" )
12086
12187 with self .assertRaises (DeleteDataError ):
12288 self .myclient .delete_opa_data ("play" )
123-
124- # TODO #check with owner of client
125- # self.assertEqual(dict(), self.myclient.check_permission())
0 commit comments