def test_duplicated_device_name(self): check = AgentCheck() tags = [] device_name = 'foo' check._normalize_tags_type(tags, device_name) normalized_tags = check._normalize_tags_type(tags, device_name) assert len(normalized_tags) == 1
def test_unicode_device_name(self): check = AgentCheck() tags = [] device_name = u'unicode_string' normalized_tags = check._normalize_tags_type(tags, device_name) normalized_device_tag = normalized_tags[0] assert isinstance(normalized_device_tag, bytes)
def test_unicode_string(self): check = AgentCheck() tag = u'unicode:string' tags = [tag] normalized_tags = check._normalize_tags_type(tags, None) normalized_tag = normalized_tags[0] assert normalized_tags is not tags assert normalized_tag == tag.encode('utf-8')
def test_bytes_string(self): check = AgentCheck() tag = b'bytes:string' tags = [tag] normalized_tags = check._normalize_tags_type(tags, None) normalized_tag = normalized_tags[0] assert normalized_tags is not tags # Ensure no new allocation occurs assert normalized_tag is tag