def create_config():
    return Config(cluster=RandomCluster(urls=helper.TEST_CLUSTER_URLS),
                  timeout_seconds=10,
                  back_off=StepBackOffStrategy(steps=[1]),
                  ttl_seconds=None,
                  auth=BasicAuth(username=helper.TEST_USERNAME,
                                 password=helper.TEST_PASSWORD),
                  disable_database_delete=False,
                  disable_collection_delete=False)
 def test_disable_delete(self):
     cfg = Config(cluster=RandomCluster(urls=helper.TEST_CLUSTER_URLS),
                  timeout_seconds=10,
                  back_off=StepBackOffStrategy(steps=[1]),
                  ttl_seconds=None,
                  auth=BasicAuth(username=helper.TEST_USERNAME,
                                 password=helper.TEST_PASSWORD))
     db = cfg.database(helper.TEST_ARANGO_DB)
     coll = db.collection('test_coll')
     self.assertRaises(AssertionError, lambda: coll.force_delete())
Example #3
0
 def test_code_as_config_basic_auth(self):
     config = Config(
         cluster=RandomCluster(
             urls=['http://127.0.0.1:8529']),  # see Cluster Styles
         timeout_seconds=3,
         back_off=StepBackOffStrategy([0.1, 0.5, 1, 1,
                                       1]),  # see Back Off Strategies
         auth=BasicAuth(username='******', password=''),
         ttl_seconds=31622400)
     self.assertIsNotNone(config)
Example #4
0
 def test_database_exists(self):
     cfg = Config(
         cluster=RandomCluster(urls=helper.TEST_CLUSTER_URLS),
         timeout_seconds=10,
         back_off=StepBackOffStrategy(steps=[1]),
         ttl_seconds=None,
         auth=BasicAuth(
             username=helper.TEST_USERNAME,
             password=helper.TEST_PASSWORD
         )
     )
     db = cfg.database(helper.TEST_ARANGO_DB)
     self.assertFalse(db.check_if_exists())
Example #5
0
    def test_collection_default_ttl(self):
        cfg = Config(cluster=RandomCluster(urls=helper.TEST_CLUSTER_URLS),
                     timeout_seconds=10,
                     back_off=StepBackOffStrategy(steps=[1]),
                     ttl_seconds=2,
                     auth=BasicAuth(username=helper.TEST_USERNAME,
                                    password=helper.TEST_PASSWORD),
                     disable_database_delete=False)

        db = cfg.database(helper.TEST_ARANGO_DB)
        self.assertTrue(db.create_if_not_exists())

        coll = db.collection('test_coll')
        self.assertTrue(coll.create_if_not_exists())

        coll.create_or_overwrite_doc('test_doc', {'foo': 3})
        self.assertEqual(coll.read_doc('test_doc'), {'foo': 3})
        self.assertTrue(db.force_delete())
    def test_protect(self):
        cfg = Config(cluster=RandomCluster(urls=helper.TEST_CLUSTER_URLS),
                     timeout_seconds=10,
                     back_off=StepBackOffStrategy(steps=[1]),
                     ttl_seconds=None,
                     auth=BasicAuth(username=helper.TEST_USERNAME,
                                    password=helper.TEST_PASSWORD),
                     disable_database_delete=False,
                     disable_collection_delete=False,
                     protected_collections=['test_coll'])
        db = cfg.database(helper.TEST_ARANGO_DB)
        coll = db.collection('test_coll')
        self.assertRaises(AssertionError, lambda: coll.force_delete())

        self.assertTrue(db.create_if_not_exists())
        coll = db.collection('test_coll2')
        self.assertFalse(coll.force_delete())
        self.assertTrue(db.force_delete())
Example #7
0
 def test_recover(self):
     auth = BasicAuth(
         username=helper.TEST_USERNAME,
         password=helper.TEST_PASSWORD
     )
     self.assertFalse(auth.try_recover_auth_failure())