示例#1
0
    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
示例#2
0
 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)
示例#3
0
 def test_writer(self):
     writer = Index.writer(DummyClass())
     assert_is_instance(writer, AsyncWriter)
示例#4
0
 def test_get(self):
     index = Index.get(DummyClass())
     assert_equals(index.indexname, DummyClass().__class__.__name__.lower())
示例#5
0
 def _store(self):
     return Store(Index.get_path(self))