# Path: recommender/items.py
# class Item(ndb.Model):
#   def ItemId(self):
# def UrlToItemId(url):
# def UrlsToItemIds(urls):
# def ItemIdsToUrls(item_ids):
# def ItemIdToUrl(item_id):
# def ItemIdsToBytes(item_ids):
# def ItemIdsFromBytes(string):


import unittest
from recommender import items
from google.appengine.ext import testbed
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.





class ItemsTest(unittest.TestCase):

  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

  def tearDown(self):
    self.testbed.deactivate()

  def testSerialization(self):
    self.assertEqual([1, 2, 3],
                     items.ItemIdsFromBytes(items.ItemIdsToBytes([1, 2, 3])))

    self.assertEqual([], items.ItemIdsFromBytes(items.ItemIdsToBytes([])))

  def testConversion(self):
    # Checks that nothing is returned for non-existing item id.
    self.assertEqual({}, items.ItemIdsToUrls([123]))

    id_a = items.UrlToItemId('a')

# Path: recommender/items.py
# class Item(ndb.Model):
#   def ItemId(self):
# def UrlToItemId(url):
# def UrlsToItemIds(urls):
# def ItemIdsToUrls(item_ids):
# def ItemIdToUrl(item_id):
# def ItemIdsToBytes(item_ids):
# def ItemIdsFromBytes(string):


# Path: recommender/items_test.py
import unittest
from recommender import items
from google.appengine.ext import testbed

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.





class ItemsTest(unittest.TestCase):

  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

  def tearDown(self):
    self.testbed.deactivate()

  def testSerialization(self):
    self.assertEqual([1, 2, 3],
                     items.ItemIdsFromBytes(items.ItemIdsToBytes([1, 2, 3])))

    self.assertEqual([], items.ItemIdsFromBytes(items.ItemIdsToBytes([])))

  def testConversion(self):
    # Checks that nothing is returned for non-existing item id.
    self.assertEqual({}, items.ItemIdsToUrls([123]))

    id_a = items.UrlToItemId('a')

    id_b = items.UrlToItemId('b')