# Path: pymatgen/db/tests/common.py
# class ComponentTest(unittest.TestCase):
#     DB = "testdb"
#     SRC = "source"
#     DST = "dest"
# 
#     MGBUILD_CMD = ["mgbuild", "run"]
# 
#     def setUp(self):
#         self.db = self.connect(True)
#         self.src, self.dst = self.db[self.SRC], self.db[self.DST]
#         self.src_conf, self.dst_conf = self.create_configs()
# 
#     def mgbuild(self, args):
#         try:
#             s = subprocess.check_output(self.MGBUILD_CMD + args, stderr=subprocess.STDOUT)
#         except subprocess.CalledProcessError as err:
#             print(f"ERROR: {err.output}")
#             raise
#         return s
# 
#     def connect(self, clear=False):
#         """Connect to Mongo DB
# 
#         :return: pymongo Database
#         """
#         c = pymongo.MongoClient()
#         db = c[self.DB]
#         if clear:
#             for coll in self.SRC, self.DST:
#                 db[coll].remove()
#                 tcoll = coll + "." + CollectionTracker.TRACKING_NAME
#                 db[tcoll].remove()  # remove tracking as well
#         return db
# 
#     def get_record(self, i):
#         return {"number": i, "data": [1, 2, 3], "name": f"mp-{i:d}"}
# 
#     def add_records(self, coll, n):
#         for i in range(n):
#             coll.insert_one(self.get_record(i))
# 
#     def create_configs(self):
#         base = {
#             "host": "localhost",
#             "port": 27017,
#             "database": self.DB,
#             "collection": None,
#         }
#         files = []
#         for coll in (self.SRC, self.DST):
#             f = tempfile.NamedTemporaryFile(suffix=".json")
#             base["collection"] = coll
#             json.dump(base, f)
#             f.flush()
#             files.append(f)
#         return files
# 
#     def tearDown(self):
#         pass
# 
#     def run_command(self, args, options):
#         """Run the command-line given by the list
#         in `args`, adding the dictionary given by
#         options as long-form --{key}=value pairs.
#         """
#         for key, value in options:
#             args.append(f"--{key}")
#             if value:
#                 args.append(value)
#         return subprocess.call(args)
# 
# def get_component_logger(name, strm=sys.stdout):
#     log = logging.getLogger(name)
#     if "TEST_DEBUG" in os.environ:
#         log.setLevel(logging.DEBUG)
#     else:
#         log.setLevel(logging.INFO)
#     _h = logging.StreamHandler(strm)
#     log.addHandler(_h)
#     return log


import logging
import time
import unittest
from pymatgen.db.tests.common import ComponentTest, get_component_logger
"""
Component-level tests for builder.
"""
__author__ = "Dan Gunter <dkgunter@lbl.gov>"
__date__ = "4/24/14"

# Stdlib

# Package

_log = get_component_logger("comp_incr")



# Path: pymatgen/db/tests/common.py
# class ComponentTest(unittest.TestCase):
#     DB = "testdb"
#     SRC = "source"
#     DST = "dest"
# 
#     MGBUILD_CMD = ["mgbuild", "run"]
# 
#     def setUp(self):
#         self.db = self.connect(True)
#         self.src, self.dst = self.db[self.SRC], self.db[self.DST]
#         self.src_conf, self.dst_conf = self.create_configs()
# 
#     def mgbuild(self, args):
#         try:
#             s = subprocess.check_output(self.MGBUILD_CMD + args, stderr=subprocess.STDOUT)
#         except subprocess.CalledProcessError as err:
#             print(f"ERROR: {err.output}")
#             raise
#         return s
# 
#     def connect(self, clear=False):
#         """Connect to Mongo DB
# 
#         :return: pymongo Database
#         """
#         c = pymongo.MongoClient()
#         db = c[self.DB]
#         if clear:
#             for coll in self.SRC, self.DST:
#                 db[coll].remove()
#                 tcoll = coll + "." + CollectionTracker.TRACKING_NAME
#                 db[tcoll].remove()  # remove tracking as well
#         return db
# 
#     def get_record(self, i):
#         return {"number": i, "data": [1, 2, 3], "name": f"mp-{i:d}"}
# 
#     def add_records(self, coll, n):
#         for i in range(n):
#             coll.insert_one(self.get_record(i))
# 
#     def create_configs(self):
#         base = {
#             "host": "localhost",
#             "port": 27017,
#             "database": self.DB,
#             "collection": None,
#         }
#         files = []
#         for coll in (self.SRC, self.DST):
#             f = tempfile.NamedTemporaryFile(suffix=".json")
#             base["collection"] = coll
#             json.dump(base, f)
#             f.flush()
#             files.append(f)
#         return files
# 
#     def tearDown(self):
#         pass
# 
#     def run_command(self, args, options):
#         """Run the command-line given by the list
#         in `args`, adding the dictionary given by
#         options as long-form --{key}=value pairs.
#         """
#         for key, value in options:
#             args.append(f"--{key}")
#             if value:
#                 args.append(value)
#         return subprocess.call(args)
# 
# def get_component_logger(name, strm=sys.stdout):
#     log = logging.getLogger(name)
#     if "TEST_DEBUG" in os.environ:
#         log.setLevel(logging.DEBUG)
#     else:
#         log.setLevel(logging.INFO)
#     _h = logging.StreamHandler(strm)
#     log.addHandler(_h)
#     return log


# Path: pymatgen/db/builders/tests/comp_incr.py
import logging
import time
import unittest
from pymatgen.db.tests.common import ComponentTest, get_component_logger

"""
Component-level tests for builder.
"""
__author__ = "Dan Gunter <dkgunter@lbl.gov>"
__date__ = "4/24/14"

# Stdlib

# Package

_log = get_component_logger("comp_incr")



class BuilderComponentTest(ComponentTest):