Beispiel #1
0
 def test_worker_organization(self):
     dump_things_worker(self.ckan, 'organizations', {},
         stdin=BytesIO(b'"cd"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title":"Super Trouper"})
Beispiel #2
0
 def test_worker_error(self):
     dump_things_worker(self.ckan, 'datasets', {},
         stdin=BytesIO(b'"99"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, "NotFound")
     self.assertEqual(data, None)
Beispiel #3
0
 def test_worker_group(self):
     dump_things_worker(self.ckan, 'groups', {},
         stdin=BytesIO(b'"ab"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title":"ABBA"})
Beispiel #4
0
 def _worker_pool_with_data(self, cmd, processes, job_iter):
     worker_stdin = BytesIO(b''.join(v for i, v in job_iter))
     worker_stdout = BytesIO()
     dump_things_worker(self.ckan,
                        'datasets', {'--datastore-fields': True},
                        stdin=worker_stdin,
                        stdout=worker_stdout)
     for i, v in enumerate(worker_stdout.getvalue().strip().split(b'\n')):
         yield [[], i, v]
 def test_worker_error(self):
     dump_things_worker(self.ckan, 'datasets',
         {'--insecure': False},
         stdin=BytesIO(b'"99"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, "NotFound")
     self.assertEqual(data, None)
 def test_worker_organization(self):
     dump_things_worker(self.ckan, 'organizations',
         {'--insecure': False},
         stdin=BytesIO(b'"cd"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title":"Super Trouper"})
Beispiel #7
0
 def _worker_pool_with_data(self, cmd, processes, job_iter):
     worker_stdin = BytesIO(b''.join(v for i, v in job_iter))
     worker_stdout = BytesIO()
     dump_things_worker(self.ckan, 'datasets', {
         '--datastore-fields': True},
         stdin=worker_stdin,
         stdout=worker_stdout)
     for i, v in enumerate(worker_stdout.getvalue().strip().split(b'\n')):
         yield [[], i, v]
Beispiel #8
0
 def test_worker_group(self):
     dump_things_worker(self.ckan,
                        'groups', {},
                        stdin=BytesIO(b'"ab"\n'),
                        stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title": "ABBA"})
Beispiel #9
0
 def test_worker_one(self):
     rval = dump_things_worker(self.ckan, 'datasets', {},
         stdin=BytesIO(b'"34"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title":"Thirty-four"})
Beispiel #10
0
 def test_worker_one(self):
     rval = dump_things_worker(self.ckan,
                               'datasets', {'--datastore-fields': False},
                               stdin=BytesIO(b'"34"\n'),
                               stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response[-1:], b'\n')
     timstamp, error, data = json.loads(response.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data["title"], "Thirty-four")
Beispiel #11
0
 def test_worker_two(self):
     rval = dump_things_worker(self.ckan, 'datasets', {},
         stdin=BytesIO(b'"12"\n"34"\n'), stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response.count(b'\n'), 2, response)
     self.assertEqual(response[-1:], b'\n')
     r1, r2 = response.split(b'\n', 1)
     timstamp, error, data = json.loads(r1.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title":"Twelve"})
     timstamp, error, data = json.loads(r2.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data, {"title":"Thirty-four"})
Beispiel #12
0
 def test_worker_two(self):
     rval = dump_things_worker(self.ckan,
                               'datasets', {'--datastore-fields': False},
                               stdin=BytesIO(b'"12"\n"34"\n'),
                               stdout=self.stdout)
     response = self.stdout.getvalue()
     self.assertEqual(response.count(b'\n'), 2, response)
     self.assertEqual(response[-1:], b'\n')
     r1, r2 = response.split(b'\n', 1)
     timstamp, error, data = json.loads(r1.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data["title"], "Twelve")
     timstamp, error, data = json.loads(r2.decode('UTF-8'))
     self.assertEqual(error, None)
     self.assertEqual(data["title"], "Thirty-four")