Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: talos/openscrape
base: 4607746c41
...
head fork: talos/openscrape
compare: 43267c9c14
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
BIN  server/proxy/bin/caustic.jar
View
Binary file not shown
38 server/proxy/test/test_proxy_integration.py
View
@@ -74,6 +74,12 @@ def test_requires_id(self):
self.assertEquals(400, r.status_code)
self.assertRegexpMatches(r.content, '(?i)id.* not found')
+ def test_echoes_id(self):
+ """Returns same ID as sent.
+ """
+ r = requests.post(URL, data=json.dumps({'id': 'foo', 'instruction': 'bar'}))
+ self.assertEquals(json.loads(r.content)['id'], 'foo')
+
def test_default_uri(self):
"""Should default the request URI to the same as the proxy.
"""
@@ -86,9 +92,37 @@ def test_default_uri(self):
def test_invalid_instruction(self):
"""Should return a failed if the instruction is invalid
"""
- pass
+ invalid = {
+ 'id': 'foo',
+ 'instruction': {
+ 'load': 'http://www.google.com',
+ 'find': 'foo'
+ }
+ }
+ r = requests.post(URL, data=json.dumps(invalid))
+ self.assertEqual(200, r.status_code)
+ response = json.loads(r.content)
+ self.assertEqual('failed', response['status'])
+ self.assertRegexpMatches(response['failed'], '(?i)cannot define both')
def test_request_simple_google(self):
"""Standard google request.
"""
- pass
+ request = {
+ 'id': 'foo',
+ 'force': True,
+ 'instruction': {
+ 'load': 'http://www.google.com/search?q=foo',
+ 'then': {
+ 'name': 'after foo',
+ 'find': 'foo(\w*)',
+ 'replace': '$1'
+ }
+ }
+ }
+ r = requests.post(URL, data=json.dumps(request))
+ self.assertEquals(200, r.status_code)
+ response = json.loads(r.content)
+ self.assertEqual('loaded', response['status'])
+ values = response['children'].values()[0][0]['children']
+ self.assertIn('bar', values)

No commit comments for this range

Something went wrong with that request. Please try again.