def test_persist_template_definitions(self): """ check that template is saved to the database """ persistable_temp = self.sample_templates.get("persistable") templates.load_templates(persistable_temp) scheme = persistable_temp["scheme"] temp_record_db = self.db.templates.find({"_id": scheme}) self.assertEqual(temp_record_db.count(), 1)
def setUp(self): self.temps = json.load(file("tests/sample_data/template_definition_v2.json")) self.extras = {"security": {"DSS": "dss_pass"}, "customer": "larry"} templates.load_templates(self.temps) provider_details.load_providers() self.id = "/agreement/4545-4545454-sdasdas" self.compute_id = "/compute/ccccccc-ddddddd" self.link_id = "/agreement_link/lllllll-ddddddd"
def setUp(self): self.temps = json.load( file("tests/sample_data/template_definition_v2.json")) self.extras = {"security": {"DSS": "dss_pass"}, "customer": "larry"} templates.load_templates(self.temps) provider_details.load_providers() self.id = "/agreement/4545-4545454-sdasdas" self.compute_id = "/compute/ccccccc-ddddddd" self.link_id = "/agreement_link/lllllll-ddddddd"
def test_update_template_in_db(self): """ Test to ensure that the same template definition is not saved twice and updates the db record """ persistable_temp = self.sample_templates.get("persistable") templates.load_templates(persistable_temp) persistable_temp["fake_attr"] = "dummy_value" templates.load_templates(persistable_temp) key = persistable_temp["scheme"] db_record = self.db.templates.find({"_id": key}) self.assertEqual(db_record.count(), 1) self.assertIn("fake_attr", db_record[0])
def init_environment(): """ Initialise MCN Provider details """ # Load Templates temps_dss = json.load(file("configs/template_definition_DSS.json")) templates.load_templates(temps_dss) #Add Providers login credentials provider_details.load_providers() #Add monitoring capabilities and Collectos's API monitoring_details.load_monitoring_capabilities() clean_violation_from_db()
def _load_template_database(self): # load template definition into database tmps = json.load(file("tests/sample_data/template_definition_v2.json")) templates.load_templates(tmps) return tmps