Skip to content

Commit

Permalink
FEAT: add BroodRepositoryInfo.update to update to new instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
cournape committed Jul 11, 2015
1 parent d92c072 commit d284b3b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions enstaller/repository_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def __init__(self, store_url, name, platform=None, python_tag=None):
self._path = ("/api/v0/json/indices/{0._name}/{0._platform}/"
"{0._python_tag}/eggs".format(self))

def update(self, platform=None, python_tag=None):
return BroodRepositoryInfo(
self._store_url, self._name, platform, python_tag
)

@property
def index_url(self):
return urllib.parse.urljoin(self._store_url, self._path)
Expand Down
28 changes: 28 additions & 0 deletions enstaller/tests/test_repository_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,34 @@ def test_eq_and_hashing(self):
self.assertNotEqual(info1, info3)
self.assertTrue(info1 != info3)

def test_update(self):
# Given
store_url = "https://acme.com"
name = "enthought/free"
python_tag = PythonImplementation.from_string("cp27").pep425_tag

r_index_url = ("https://acme.com/api/v0/json/indices/{0}/{1}/{2}/eggs"
.format(name, enstaller.plat.custom_plat, python_tag))

# When
info = BroodRepositoryInfo(store_url, name, python_tag=python_tag)

# Then
self.assertEqual(info.index_url, r_index_url)
self.assertEqual(info.name, name)

# Given
python_tag = "cp34"
r_index_url = ("https://acme.com/api/v0/json/indices/{0}/{1}/{2}/eggs"
.format(name, enstaller.plat.custom_plat, python_tag))

# When
info = info.update(python_tag=python_tag)

# Then
self.assertEqual(info.index_url, r_index_url)
self.assertEqual(info.name, name)

def test_simple_python_package(self):
# Given
store_url = "https://acme.com"
Expand Down

0 comments on commit d284b3b

Please sign in to comment.