Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions tests/test_trace_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,9 @@ def test_install_id_from_file_never_raises_for_a_bad_path(self):
def test_a_disabled_client_never_makes_up_or_writes_an_install_id(self):
directory = self._tmpdir()
path = os.path.join(directory, "install-id")
os.environ["DO_NOT_TRACK"] = "1"
by_environment = TraceClient(self.base_url, "MyGame", "1.2.3", key="k", install_id_file=path,
install_id="explicit")
del os.environ["DO_NOT_TRACK"]
with mock.patch.dict(os.environ, {"DO_NOT_TRACK": "1"}):
by_environment = TraceClient(self.base_url, "MyGame", "1.2.3", key="k", install_id_file=path,
install_id="explicit")
by_config = TraceClient(self.base_url, "MyGame", "1.2.3", key="k", enabled=False, install_id_file=path)
by_no_key = TraceClient(self.base_url, "MyGame", "1.2.3", install_id_file=path)
for client in (by_environment, by_config, by_no_key):
Expand All @@ -507,7 +506,9 @@ def test_explicit_install_id_is_trimmed_sent_and_wins_over_the_file(self):

def test_blank_install_id_is_none_and_an_overlong_one_is_rejected(self):
for blank in (None, "", " "):
self.assertIsNone(TraceClient(self.base_url, "MyGame", "1.2.3", key="k", install_id=blank).install_id)
client = TraceClient(self.base_url, "MyGame", "1.2.3", key="k", install_id=blank)
self.assertIsNone(client.install_id, repr(blank))
client.close()
with self.assertRaises(ValueError):
TraceClient(self.base_url, "MyGame", "1.2.3", key="k", install_id="x" * (MAX_TAG_LENGTH + 1))
with self.assertRaises(ValueError, msg="rejected even on a disabled client, like the version"):
Expand Down
5 changes: 3 additions & 2 deletions trace_client/trace_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
REASON_CONFIG = "config"
REASON_NO_KEY = "no key"

#: The longest a program version may be, after trimming: the trace server's
#: limit on a tag value.
#: The longest a tag value the client sets itself -- the program version, the
#: installation ID -- may be, after trimming: the trace server's limit on a
#: tag value.
MAX_TAG_LENGTH = 255

#: The most tags one event carries: the trace server's limit. The ``install``
Expand Down
Loading