Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
BIN  server/proxy/bin/caustic.jar
Binary file not shown
38 server/proxy/test/test_proxy_integration.py
@@ -74,6 +74,12 @@ def test_requires_id(self):
74 74 self.assertEquals(400, r.status_code)
75 75 self.assertRegexpMatches(r.content, '(?i)id.* not found')
76 76
  77 + def test_echoes_id(self):
  78 + """Returns same ID as sent.
  79 + """
  80 + r = requests.post(URL, data=json.dumps({'id': 'foo', 'instruction': 'bar'}))
  81 + self.assertEquals(json.loads(r.content)['id'], 'foo')
  82 +
77 83 def test_default_uri(self):
78 84 """Should default the request URI to the same as the proxy.
79 85 """
@@ -86,9 +92,37 @@ def test_default_uri(self):
86 92 def test_invalid_instruction(self):
87 93 """Should return a failed if the instruction is invalid
88 94 """
89   - pass
  95 + invalid = {
  96 + 'id': 'foo',
  97 + 'instruction': {
  98 + 'load': 'http://www.google.com',
  99 + 'find': 'foo'
  100 + }
  101 + }
  102 + r = requests.post(URL, data=json.dumps(invalid))
  103 + self.assertEqual(200, r.status_code)
  104 + response = json.loads(r.content)
  105 + self.assertEqual('failed', response['status'])
  106 + self.assertRegexpMatches(response['failed'], '(?i)cannot define both')
90 107
91 108 def test_request_simple_google(self):
92 109 """Standard google request.
93 110 """
94   - pass
  111 + request = {
  112 + 'id': 'foo',
  113 + 'force': True,
  114 + 'instruction': {
  115 + 'load': 'http://www.google.com/search?q=foo',
  116 + 'then': {
  117 + 'name': 'after foo',
  118 + 'find': 'foo(\w*)',
  119 + 'replace': '$1'
  120 + }
  121 + }
  122 + }
  123 + r = requests.post(URL, data=json.dumps(request))
  124 + self.assertEquals(200, r.status_code)
  125 + response = json.loads(r.content)
  126 + self.assertEqual('loaded', response['status'])
  127 + values = response['children'].values()[0][0]['children']
  128 + self.assertIn('bar', values)

No commit comments for this range

Something went wrong with that request. Please try again.