analytics: send report without loading it to memory

shout-out to @Suor for the suggestion
This commit is contained in:
Mr. Outis
2019-12-02 17:51:32 -06:00
parent 656f986542
commit 946dfc1400
2 changed files with 4 additions and 4 deletions
+2 -3
View File
@@ -52,11 +52,10 @@ def is_enabled():
def send(path):
url = "https://analytics.dvc.org"
headers = {"content-type": "application/json"}
with open(str(path)) as fobj:
report = json.load(fobj)
requests.post(url, json=report, timeout=5)
requests.post(url, data=fobj, headers=headers, timeout=5)
def scm_in_use():
+2 -1
View File
@@ -34,7 +34,8 @@ def test_send(mock_post, tmp_path):
fname.write_text(str(json.dumps(report)))
analytics.send(fname)
mock_post.assert_called_with(url, json=report, timeout=5)
assert mock_post.called
assert mock_post.call_args.args[0] == url
@pytest.mark.parametrize(