def test_gridfs(self):
     """Test the gridfs property is set correctly."""
     equivalent_namespace_configs = (
         NamespaceConfig(gridfs_set=["db1.*"]),
         NamespaceConfig(namespace_options={"db1.*": {
             "gridfs": True
         }}))
     for namespace_config in equivalent_namespace_configs:
         self.assertEqual(namespace_config.unmap_namespace("db1.col1"),
                          "db1.col1")
         self.assertEqual(namespace_config.unmap_namespace("db1.col2"),
                          "db1.col2")
         self.assertEqual(
             namespace_config.lookup("db1.col1"),
             Namespace(dest_name="db1.col1",
                       source_name="db1.col1",
                       gridfs=True))
         self.assertListEqual(namespace_config.map_db("db1"), ["db1"])
         self.assertEqual(namespace_config.map_namespace("db1.col1"),
                          "db1.col1")
         self.assertIsNone(namespace_config.map_namespace("db2.col4"))
         self.assertTrue(namespace_config.lookup("db1.col1").gridfs)
         self.assertEqual(namespace_config.gridfs_namespace("db1.col1"),
                          "db1.col1")
         self.assertIsNone(namespace_config.gridfs_namespace("not.gridfs"))
Ejemplo n.º 2
0
 def test_include_wildcard(self):
     """Test including namespaces with wildcards"""
     equivalent_namespace_configs = (
         NamespaceConfig(namespace_set=["db1.*"]),
         NamespaceConfig(namespace_options={"db1.*": {}}),
         NamespaceConfig(namespace_options={"db1.*": True}),
         NamespaceConfig(namespace_options={"db1.*": {"rename": "db1.*"}}),
     )
     for namespace_config in equivalent_namespace_configs:
         self.assertEqual(namespace_config.unmap_namespace("db1.col1"), "db1.col1")
         self.assertEqual(namespace_config.unmap_namespace("db1.col2"), "db1.col2")
         self.assertEqual(
             namespace_config.lookup("db1.col1"),
             Namespace(dest_name="db1.col1", source_name="db1.col1"),
         )
         self.assertListEqual(namespace_config.map_db("db1"), ["db1"])
         self.assertEqual(namespace_config.map_namespace("db1.col1"), "db1.col1")
         self.assertIsNone(namespace_config.map_namespace("db2.col4"))
Ejemplo n.º 3
0
def get_test_namespace():
    """Returns the Namespace for testing plugins."""
    return Namespace(plugins=TEST_PLUGIN_CONFIGS)