Skip to content

Simplify some code, use less confusing crypto nonsense #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 2, 2014
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
10 changes: 5 additions & 5 deletions tests/search/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ def test_reindex(self, monkeypatch):

assert index.es.indices.create.calls == [
pretend.call(
"warehouse1e4a1b03",
"warehouse30303030",
{"mappings": {"fake": {"foo": "bar"}}},
),
]
assert index.update_alias.calls == [
pretend.call("warehouse", "warehouse1e4a1b03", keep_old=False),
pretend.call("warehouse", "warehouse30303030", keep_old=False),
]
assert index.types["fake"].index_all.calls == [
pretend.call(index="warehouse1e4a1b03"),
pretend.call(index="warehouse30303030"),
]

def test_reindex_no_alias(self, monkeypatch):
Expand Down Expand Up @@ -90,13 +90,13 @@ def test_reindex_no_alias(self, monkeypatch):

assert index.es.indices.create.calls == [
pretend.call(
"warehouse1e4a1b03",
"warehouse30303030",
{"mappings": {"fake": {"foo": "bar"}}},
),
]
assert index.update_alias.calls == []
assert index.types["fake"].index_all.calls == [
pretend.call(index="warehouse1e4a1b03"),
pretend.call(index="warehouse30303030"),
]

def test_update_alias(self):
Expand Down
4 changes: 2 additions & 2 deletions warehouse/search/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from __future__ import absolute_import, division, print_function
from __future__ import unicode_literals

import hashlib
import binascii
import os

from elasticsearch import Elasticsearch, TransportError
Expand Down Expand Up @@ -45,7 +45,7 @@ def reindex(self, index=None, alias=True, keep_old=False):
# Generate an Index Name for Warehouse
index = "".join([
index if index is not None else self._index,
hashlib.md5(os.urandom(16)).hexdigest()[:8],
binascii.hexlify(os.urandom(4)),
])

# Create this index
Expand Down