Beispiel #1
0
    def setUpClass(cls):
        """Create a test bigtable instance."""
        data_store_test._DataStoreTest.setUpClass()
        cls.test_project_id = config_lib.CONFIG[
            "CloudBigtable.test_project_id"]

        if not cls.test_project_id:
            raise unittest.SkipTest(
                "No CloudBigtable.test_project_id set, skipping.")

        cls.db = cloud_bigtable_data_store.CloudBigTableDataStore()
        cls.btclient = bigtable.Client(project=cls.test_project_id, admin=True)

        # Ideally we wouldn't stand up a new instance for each test run, but
        # deleting an instance just marks it for delete in 7 days and you can't
        # recreate with the same name. Users can set instance_id=[yourid] to test
        # with an existing instance.
        if not cls.instance_id:
            cls.instance_id = "".join((cls.TEST_BIGTABLE_INSTANCE_PREFIX,
                                       str(random.randrange(1, 1000))))
        cls.db.Initialize(project_id=cls.test_project_id,
                          instance_id=cls.instance_id)

        # Hold a reference to the instance in our class level btclient so tests can
        # access it.
        cls.btinstance = cls.btclient.instance(cls.instance_id)
Beispiel #2
0
    def setUp(self):
        self.btclient_patcher = mock.patch.object(bigtable,
                                                  "Client",
                                                  autospec=True)
        self.btclient_patcher.start()

        self.db = cloud_bigtable_data_store.CloudBigTableDataStore()
        self.db.table = mock.MagicMock()
        self.btclient = bigtable.Client(project="something", admin=True)