mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
- Use `version.py` to compute a dynamic version stored in `__version__`. Version information was scattered across the source code (`VERSION_BASE`, `VERSION`, `__version__`, and `version.py`). - Read `__version__` from `setup.py` and **pin** it using custom `build_py` command class. This way, we can maintain consistancy between the build version and the runtime one. Also, this gives us the ability to run `setup.py` without depending on on `dvc` itself. Close #1824
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import os
|
|
import json
|
|
import mock
|
|
|
|
from dvc import __version__
|
|
from tests.basic_env import TestDvc
|
|
|
|
|
|
class MockResponse(object):
|
|
def __init__(self, json_data, status_code):
|
|
self.json_data = json_data
|
|
self.status_code = status_code
|
|
|
|
def json(self):
|
|
return self.json_data
|
|
|
|
|
|
def mocked_requests_get(*args, **kwargs):
|
|
class MockResponse:
|
|
def __init__(self, json_data, status_code):
|
|
self.json_data = json_data
|
|
self.status_code = status_code
|
|
|
|
def json(self):
|
|
return self.json_data
|
|
|
|
return MockResponse({"version": __version__}, 200)
|
|
|
|
|
|
class TestUpdater(TestDvc):
|
|
@mock.patch("requests.get", side_effect=mocked_requests_get)
|
|
def test_fetch(self, mock_get):
|
|
self.assertFalse(os.path.exists(self.dvc.updater.updater_file))
|
|
self.dvc.updater.fetch(detach=False)
|
|
mock_get.assert_called_once()
|
|
self.assertTrue(os.path.isfile(self.dvc.updater.updater_file))
|
|
with open(self.dvc.updater.updater_file, "r") as fobj:
|
|
info = json.load(fobj)
|
|
self.assertEqual(info["version"], __version__)
|