# Path: pymatgen/db/util.py
# def collection_keys(coll, sep="."):
#     """Get a list of all (including nested) keys in a collection.
#     Examines the first document in the collection.
# 
#     :param sep: Separator for nested keys
#     :return: List of str
#     """
# 
#     def _keys(x, pre=""):
#         for k in x:
#             yield (pre + k)
#             if isinstance(x[k], dict):
#                 yield from _keys(x[k], pre + k + sep)
# 
#     return list(_keys(coll.find_one()))


import unittest
from pymatgen.db.util import collection_keys
"""
Tests for pymatgen.db.util
"""
__author__ = "dang"



class FakeCollection:
    """Collection that emulates find_one()."""

    def __init__(self, data):
        self.data = data

    def find_one(self):
        return self.data


class KeysTestCase(unittest.TestCase):
    """Test collection_keys."""

    def test_flat(self):
        keys = ["a", "b", "C"]
        coll = FakeCollection(dict.fromkeys(keys))

# Path: pymatgen/db/util.py
# def collection_keys(coll, sep="."):
#     """Get a list of all (including nested) keys in a collection.
#     Examines the first document in the collection.
# 
#     :param sep: Separator for nested keys
#     :return: List of str
#     """
# 
#     def _keys(x, pre=""):
#         for k in x:
#             yield (pre + k)
#             if isinstance(x[k], dict):
#                 yield from _keys(x[k], pre + k + sep)
# 
#     return list(_keys(coll.find_one()))


# Path: pymatgen/db/tests/util_test.py
import unittest
from pymatgen.db.util import collection_keys

"""
Tests for pymatgen.db.util
"""
__author__ = "dang"



class FakeCollection:
    """Collection that emulates find_one()."""

    def __init__(self, data):
        self.data = data

    def find_one(self):
        return self.data


class KeysTestCase(unittest.TestCase):
    """Test collection_keys."""

    def test_flat(self):
        keys = ["a", "b", "C"]
        coll = FakeCollection(dict.fromkeys(keys))

        result = collection_keys(coll)