def test_update_good(self): new_record = { u'type': u'channel', u'lowerFreq': 20e6, u'upperFreq': 20e6, } index = 0 modified = self.test_data_json[:] modified[index] = new_record d = testutil.http_post(reactor, self.__url('/' + str(index)), { 'old': self.test_data_json[index], 'new': new_record }) def proceed((response, data)): if response.code >= 300: print data self.assertEqual(response.code, http.NO_CONTENT) def check(s): j = json.loads(s) self.assertEqual(j, modified) return client.getPage(self.__url('/')).addCallback(check) d.addCallback(proceed) return d
def test_create(self): new_record = { u'type': u'channel', u'lowerFreq': 20e6, u'upperFreq': 20e6, } d = testutil.http_post(reactor, self.__url('/'), { 'new': new_record }) def proceed((response, data)): if response.code >= 300: print data self.assertEqual(response.code, http.CREATED) url = 'ONLYONE'.join(response.headers.getRawHeaders('Location')) self.assertEqual(url, self.__url('/3')) # URL of new entry def check(s): j = json.loads(s) self.assertEqual(j[u'records'][u'3'], db.normalize_record(new_record)) return client.getPage(self.__url('/')).addCallback(check) d.addCallback(proceed) return d
def test_update_good(self): new_data = { u'type': u'channel', u'lowerFreq': 20e6, u'upperFreq': 20e6, u'label': u'modified', } index = u'1' modified = dict(self.response_json[u'records']) modified[index] = db.normalize_record(new_data) d = testutil.http_post(reactor, self.__url('/' + str(index)), { 'old': self.response_json[u'records'][index], 'new': new_data }) def proceed((response, data)): if response.code >= 300: print data self.assertEqual(response.code, http.NO_CONTENT) def check(s): j = json.loads(s) self.assertEqual(j[u'records'], modified) return client.getPage(self.__url('/')).addCallback(check) d.addCallback(proceed) return d