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

        if PY3:
            # Ensure no new allocation occurs
            assert normalized_tag is tag
        else:
            assert normalized_tag == tag.encode('utf-8')
Exemple #2
0
    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

        if PY3:
            assert normalized_tag == tag.decode('utf-8')
        else:
            # Ensure no new allocation occurs
            assert normalized_tag is tag
Exemple #3
0
    def test_none_value(self):
        check = AgentCheck()
        tags = [None, 'tag:foo']

        normalized_tags = check._normalize_tags_type(tags, None)
        assert normalized_tags == ['tag:foo']
Exemple #4
0
 def test_generic_tags(self, disable_generic_tags, expected_tags):
     instance = {'disable_generic_tags': disable_generic_tags}
     check = AgentCheck('myintegration', {}, [instance])
     tags = check._normalize_tags_type(tags=["foo:bar", "cluster:my_cluster", "version", "bar"])
     assert set(tags) == expected_tags