Пример #1
0
    def test_merges_multiple_conflicts(self):
        self.add_mock_conflicts(14)

        doc = copy.deepcopy(payload_telemetry_doc_ish)
        doc["receivers"]["TESTCALL"]["time_uploaded"] = \
                to_rfc3339(1300001235 + 14)

        uploader.time.time().AndReturn(1300001235.0 + 14)
        self.expect_ptlm_update_func(payload_telemetry_doc_id, doc)
        self.mocker.ReplayAll()

        self.uploader.payload_telemetry(payload_telemetry_string,
                                        payload_telemetry_metadata)

        self.mocker.VerifyAll()
Пример #2
0
    def add_mock_conflicts(self, n):
        url = "_design/payload_telemetry/_update/add_listener/" + \
                payload_telemetry_doc_id

        uploader.time.time().AndReturn(1300001234.0)
        uploader.time.time().AndReturn(1300001234.0)

        self.fake_db.res.put(url, payload=payload_telemetry_doc_ish) \
             .AndRaise(couchdbkit.exceptions.ResourceConflict)

        for i in xrange(n):
            doc = copy.deepcopy(payload_telemetry_doc_ish)
            doc["receivers"]["TESTCALL"]["time_uploaded"] = \
                    to_rfc3339(1300001235 + i)
            uploader.time.time().AndReturn(1300001235.0 + i)
            self.fake_db.res.put(url, payload=doc) \
                 .AndRaise(couchdbkit.exceptions.ResourceConflict)
Пример #3
0
    def test_ptlm_retries_conflicts(self):
        uploader.time.time().AndReturn(1300001234.0)
        uploader.time.time().AndReturn(1300001234.0)
        url = "_design/payload_telemetry/_update/add_listener/" + \
                payload_telemetry_doc_id
        self.fake_db.res.put(url, payload=payload_telemetry_doc_ish) \
             .AndRaise(couchdbkit.exceptions.ResourceConflict)

        uploader.time.time().AndReturn(1300001235.0)
        doc = copy.deepcopy(payload_telemetry_doc_ish)
        doc["receivers"]["TESTCALL"]["time_uploaded"] = to_rfc3339(1300001235)
        self.expect_ptlm_update_func(payload_telemetry_doc_id, doc)

        self.mocker.ReplayAll()

        self.uploader.payload_telemetry(payload_telemetry_string,
                                        payload_telemetry_metadata)
        self.mocker.VerifyAll()
Пример #4
0
import couchdbkit
import couchdbkit.resource
import restkit.errors
from strict_rfc3339 import timestamp_to_rfc3339_localoffset as to_rfc3339

from .. import views

from .. import uploader


telemetry_data = {"latitude": 0.1234, "longitude": 1.345,
                  "some_data": 123, "_flag": True}
telemetry_doc = {
    "data": copy.deepcopy(telemetry_data),
    "type": "listener_telemetry",
    "time_created": to_rfc3339(1300001234),
    "time_uploaded": to_rfc3339(1300001234)
}
telemetry_doc["data"]["callsign"] = "TESTCALL"
telemetry_time_doc = copy.deepcopy(telemetry_doc)
telemetry_time_doc["time_created"] = to_rfc3339(1300001232)
telemetry_time_doc["time_uploaded"] = to_rfc3339(1300001276)

info_data = {"my_radio": "Duga-3", "vehicle": "Tractor"}
info_doc = {
    "data": copy.deepcopy(info_data),
    "type": "listener_information",
    "time_created": to_rfc3339(1300001259),
    "time_uploaded": to_rfc3339(1300001259)
}
info_doc["data"]["callsign"] = "TESTCALL"