def test_list_period_of_time(self): since_date = '2017-01-01' until_date = '2017-03-31' cmd = Command.create('list since {since} until {until}'.format(since=since_date, until=until_date)) self.assertTrue(isinstance(cmd, ListCommand)) self.assertEqual(cmd.since, datetime.date(2017, 1, 1)) self.assertEqual(cmd.until, datetime.date(2017, 3, 31))
def disconnect(client): try: # remove it from the list ConnectionsManager.clients.remove(client) # close the socket listening client.socket.close() # broadcast the disconnexion message=Command.create(command=Command.LOGOUT,id=str(client.id)) ConnectionsManager.broadcast(message) print("disconnection of "+repr(client.address)) print(ConnectionsManager.clientSize()) except ValueError: print('noting to disconnect or already disconnected')
def test_list_entry_types(self): lst = Command.create('list types').run() self.assertTrue(len(lst) > 0)
def test_list_all_explicit(self): cmd = Command.create('list all') self._list_all_assertions(cmd)
def sendRefresh(self): message=Command.create(command=Command.REFRESH,user=self.publicRepresentation()) ConnectionsManager.broadcast(message)
def sendList(self): message=Command.create(command=Command.USERLIST,users=ConnectionsManager.getJsonList()) ConnectionsManager.sendTo(message,client=self)
def sendMessage(self,message,senderId): message=Command.create(command=Command.WRITE,senderid=str(senderId),content=message) print("@"+str(self.id)+" "+message) ConnectionsManager.sendTo(message,client=self)