def test_metadata_readMetaData_1(self): """verify readMetaData""" jstr = """{"backup-today": "2019-01-02", "latest-complete": "2019-01-02-012345"}""" os.makedirs(os.path.join(os.environ['HOME'], "temp_myocp"), mode=0o755, exist_ok=True) with open(os.path.join(os.environ['HOME'], "temp_myocp", ".metadata"), 'w') as fp: fp.write(jstr) metadata = MetaData(self.log, self.comms, self.settings) metadata.settings.set("settings-dir", "temp_myocp") self.assertDictEqual(metadata.meta, { "backup-today": "", "latest-complete": "" }) metadata.readMetaData() self.assertDictEqual(metadata.meta, { "backup-today": "2019-01-02", "latest-complete": "2019-01-02-012345" }) shutil.rmtree(os.path.join(os.environ['HOME'], "temp_myocp"))
def test_metadata_readMetaData_2(self): """verify readMetaData return empty json string if no such file returned from remote call""" json_str = """{}""" metadata = MetaData(self.log, self.comms, self.settings, json_str) metadata.readMetaData() self.assertDictEqual(metadata.meta, {})