def test_delete_with_id(self):
     system = LogSearchSystem(type='groonga',
                              base_url='http://search.example.com/#!/tables/Logs/search')
     system.save()
     response = self._delete(system.id)
     self.assertEquals(response.status_code, httplib.OK)
     self.assertRaises(LogSearchSystem.DoesNotExist,
                       lambda: LogSearchSystem.objects.get(id=system.id))
 def test_get_with_id(self):
     system = LogSearchSystem(type='groonga',
                              base_url='http://search.example.com/#!/tables/Logs/search')
     system.save()
     response = self._get(system.id)
     self.assertEquals(response.status_code, httplib.OK)
     record = {
         'id': system.id,
         'type': system.type,
         'base_url': system.base_url,
     }
     self.assertEquals(json.loads(response.content),
                       record)
Esempio n. 3
0
 def test_get_without_id(self):
     system = LogSearchSystem(
         type='groonga',
         base_url='http://search.example.com/#!/tables/Logs/search')
     system.save()
     response = self._get(None)
     self.assertEquals(response.status_code, httplib.OK)
     record = {
         'id': system.id,
         'type': system.type,
         'base_url': system.base_url,
     }
     self.assertEquals(json.loads(response.content), [record])
 def test_put_with_id(self):
     system = LogSearchSystem(type='groonga',
                              base_url='http://search.example.com/#!/tables/Logs/search')
     system.save()
     new_record = {
         'type': 'other',
         'base_url': 'http://search.example.net/',
     }
     response = self._put(system.id, new_record)
     self.assertEquals(response.status_code, httplib.OK)
     record = {
         'id': system.id,
         'type': new_record['type'],
         'base_url': new_record['base_url'],
     }
     self.assertEquals(json.loads(response.content),
                       record)
 def test_delete_with_id_nonexistent(self):
     system = LogSearchSystem()
     system.save()
     nonexistent_id = system.id
     system.delete()
     response = self._delete(nonexistent_id)
     self.assertEquals(response.status_code, httplib.NOT_FOUND)
 def test_get_with_id_nonexsitent(self):
     system = LogSearchSystem(type='groonga',
                              base_url='http://search.example.com/#!/tables/Logs/search')
     system.save()
     id = system.id
     system.delete()
     response = self._get(id)
     self.assertEquals(response.status_code, httplib.NOT_FOUND)
 def test_put_with_id_nonexistent(self):
     system = LogSearchSystem(type='groonga',
                              base_url='http://search.example.com/#!/tables/Logs/search')
     system.save()
     nonexistent_id = system.id
     system.delete()
     record = {
         'type': 'other',
         'base_url': 'http://search.example.net/',
     }
     response = self._put(nonexistent_id, record)
     self.assertEquals(response.status_code, httplib.NOT_FOUND)