def test_get_path(self, monkeypatch): def mock_expanduser(user): return os.getcwd().rstrip(os.sep) monkeypatch.setattr(os.path, 'expanduser', mock_expanduser) index_path = Index.get_path(DummyClass) class_name = DummyClass.__name__.lower() package = [m.lower() for m in Introspection.get_instance_path(DummyClass)] expected = os.sep.join([os.getcwd().rstrip(os.sep), '.data'] + package + [class_name]) assert index_path == expected index_path = Index.get_path(DummyClass()) assert index_path == expected
def test_get_schema(self): schema = Index.get_schema(DummyClass()) assert_is_instance(schema, Schema) fields = schema._fields.keys() for attribute in Introspection.get_storeable_attributes(DummyClass()): assert_in(attribute, fields) assert_in(InstanceIndex.cache_property, fields) assert_in(InstanceIndex.pickled_fields, fields) assert_in(InstanceIndex.instance_key, fields)
def test_writer(self): writer = Index.writer(DummyClass()) assert_is_instance(writer, AsyncWriter)
def test_get(self): index = Index.get(DummyClass()) assert_equals(index.indexname, DummyClass().__class__.__name__.lower())
def _store(self): return Store(Index.get_path(self))