def test_str_representation(self):
        # incrementally adds attributes and checks if they appear in str(item).
        # The str representation is important for several chat commands.
        identifier = UserIdentifier('foo', 'bar')
        # str needs to work without password and data
        self.assertIn('foo', str(identifier))
        self.assertIn('bar', str(identifier))

        identifier.password = '******'
        self.assertIn('passw0rd!', str(identifier))

        data = UserData()
        state_str = data.state_string()
        self.assertIn(state_str, str(data))

        # this is 1970-01-01 00:01:40
        data.valid_until = 100
        data.num_joins = 42
        data.max_num_joins = 1234
        # keep some freedoms on the actual output
        self.assertIn('1970', str(data))
        self.assertIn('00:01:40', str(data))
        self.assertIn('42', str(data))
        self.assertIn('1234', str(data))

        data_str = str(data)
        identifier.user_data = data
        self.assertIn(data_str, str(identifier))
    def test_data_state_string(self):
        check_map = {
            UserData.JOIN_STATE_WAITING: 'waiting',
            UserData.JOIN_STATE_ALLOWED: 'allowed',
            UserData.JOIN_STATE_BLOCKED: 'blocked'
        }

        for state, representation in check_map.items():
            data = UserData()
            data.join_state = state
            self.assertIn(representation, data.state_string().lower())