def test_LoadPersistentUpdateValueFlags(storage_populated, dispatcher, entry_notifier, is_server): storage = storage_populated fp = StringIO('[NetworkTables Storage 3.0]\ndouble "foo2"=1.0\n') assert storage.loadPersistent(fp=fp) is None entry = storage.m_entries.get("foo2") assert Value.makeDouble(1.0) == entry.value assert NT_PERSISTENT == entry.flags assert entry.isPersistent # client shouldn't send an update as id not assigned yet if is_server: # id assigned as this is the server; seq_num incremented dispatcher._queueOutgoing.assert_has_calls([ call(Message.entryUpdate(1, 2, entry.value), None, None), call(Message.flagsUpdate(1, NT_PERSISTENT), None, None), ]) else: assert dispatcher._queueOutgoing.call_count == 0 entry_notifier.notifyEntry.assert_has_calls([ call( 1, "foo2", entry.value, NT_NOTIFY_FLAGS | NT_NOTIFY_UPDATE | NT_NOTIFY_LOCAL, ) ]) if not is_server: assert 2 == storage.m_entries.get( "foo2").seq_num # still should be incremented
def test_SetEntryFlagsDifferentValue(storage_populated, dispatcher, entry_notifier, is_server): storage = storage_populated # update with different value results in flags update message storage.setEntryFlags("foo2", 1) entry = storage.m_entries.get("foo2") assert 1 == entry.flags if is_server: # id assigned as this is the server dispatcher._queueOutgoing.assert_has_calls( [call(Message.flagsUpdate(1, 1), None, None)]) else: # shouldn't send an update id not assigned yet assert dispatcher._queueOutgoing.call_count == 0 entry_notifier.notifyEntry.assert_has_calls( [call(1, "foo2", entry.value, NT_NOTIFY_FLAGS | NT_NOTIFY_LOCAL)])
def test_LoadPersistentUpdateFlags(storage_populated, dispatcher, entry_notifier, is_server): storage = storage_populated fp = StringIO('[NetworkTables Storage 3.0]\ndouble "foo2"=0.0\n') assert storage.loadPersistent(fp=fp) is None entry = storage.m_entries.get("foo2") assert Value.makeDouble(0.0) == entry.value assert NT_PERSISTENT == entry.flags assert entry.isPersistent if is_server: dispatcher._queueOutgoing.assert_has_calls( [call(Message.flagsUpdate(1, NT_PERSISTENT), None, None)]) else: assert dispatcher._queueOutgoing.call_count == 0 entry_notifier.notifyEntry.assert_has_calls( [call(1, "foo2", entry.value, NT_NOTIFY_FLAGS | NT_NOTIFY_LOCAL)])
def test_ProcessIncomingEntryAssignWithFlags(storage_populate_one, dispatcher, entry_notifier, is_server, conn): storage = storage_populate_one value = Value.makeDouble(1.0) storage.processIncoming(Message.entryAssign("foo", 0, 1, value, 0x2), conn) # EXPECT_CALL(*conn, proto_rev()).WillRepeatedly(Return(0x0300u)) if is_server: # server broadcasts new value/flags to all *other* connections dispatcher._queueOutgoing.assert_has_calls( [call(Message.entryAssign("foo", 0, 1, value, 0x2), None, conn)]) entry_notifier.notifyEntry.assert_has_calls( [call(0, "foo", value, NT_NOTIFY_UPDATE | NT_NOTIFY_FLAGS)]) else: # client forces flags back when an assign message is received for an # existing entry with different flags dispatcher._queueOutgoing.assert_has_calls( [call(Message.flagsUpdate(0, 0), None, None)]) entry_notifier.notifyEntry.assert_has_calls( [call(0, "foo", value, NT_NOTIFY_UPDATE)])
def test_wire_flagsUpdate(msg_round_trip): msg_round_trip(Message.flagsUpdate(0x1234, 0x42), minver=0x0300)