Beispiel #1
0
    def test_get_all_cats(self):
        new_ids = ["foo", "bar", "baz"]
        for new_id in new_ids:
            self.r.hset(
                Category.CAT_META_HASH,
                "%s:signature" % (new_id), self.cat_sig
            )

        cats = Category.get_all_categories(self.r)
        self.assertEqual(len(cats), len(new_ids) + 1)
        for cat in cats:
            self.assertEqual(cat.signature, self.cat_sig)
Beispiel #2
0
def create_mock_category(id, sig, thresh, name):
    """Create a mock category object for testing purposes.

    Args:
        id: str, system referenc (hash when not a test obj).
        sig: str, the signature we're matching against.
        thresh: float, what ratio will match sig.
        name: str, human-readable name.
    """
    cat = Category(
            redis_util.MockRedis(share_state=False),
            cat_id=id)

    cat._set_signature(sig)
    cat._set_threshold(thresh)
    cat._set_human(name)

    return cat
Beispiel #3
0
 def test_category_create(self):
     cat = Category.create(self.r, "new test category")
     self.assertEqual(cat.signature, "new test category")
     self.assertTrue(cat.cat_id)