Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1.     def test_policy_rule_evaluation(self):
  2.         try:
  3.             # create policy alice in PE1
  4.             self.assertEqual(self.pe1.post(
  5.                 suffix='policies', json={'name': 'alice'}).status_code,
  6.                              201)
  7.             # add rule to PE1
  8.             j = {'rule': 'p(x) :- q(x)', 'name': 'rule0'}
  9.             self.assertEqual(self.pe1.post(
  10.                 suffix='policies/alice/rules', json=j).status_code, 201)
  11.  
  12.             # add data to PE1
  13.             j = {'rule': 'q(1)', 'name': 'rule1'}
  14.             self.assertEqual(self.pe1.post(
  15.                 suffix='policies/alice/rules', json=j).status_code, 201)
  16.  
  17.             # add data to PE2
  18.             j = {'rule': 'q(2)', 'name': 'rule2'}
  19.             self.assertEqual(self.pe2.post(
  20.                 suffix='policies/alice/rules', json=j).status_code, 201)
  21.  
  22.             # eval on PE1
  23.             helper.retry_check_function_return_value_table(
  24.                 lambda: [x['data'] for x in
  25.                          self.pe1.get('policies/alice/tables/p/rows').json()[
  26.                         'results']],
  27.                 [[1], [2]])
  28.  
  29.             # eval on PE2
  30.             helper.retry_check_function_return_value_table(
  31.                 lambda: [x['data'] for x in
  32.                          self.pe2.get('policies/alice/tables/p/rows').json()[
  33.                         'results']],
  34.                 [[1], [2]])
  35.  
  36.         except Exception:
  37.             LOG.error('PE1 process output:\n%s' % self.read_output_file(self.outfiles[1]))
  38.             LOG.error('PE2 process output:\n%s' % self.read_output_file(self.outfiles[2]))
  39.             raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement