def test_update(self): pump = Pump() pump.set_endpoints() influx = InfluxdbUpdater({'active': True}) pump.add_updater(influx) print('***** Test update summary usage ***') with mock.patch.object(influx, 'update_summary_usage', return_value=None) as mocked: name = 'fixtures/summary-usage-dd-eu.yaml' lname = os.path.abspath(os.path.dirname(__file__))+'/'+name if os.path.isfile(lname): with open(lname, 'r') as handle: items = yaml.load(handle) pump.update_summary_usage(items) mocked.assert_called_once_with(items, 'dd-eu') print('***** Test update detailed usage ***') with mock.patch.object(influx, 'update_detailed_usage', return_value=None) as mocked: name = 'fixtures/detailed-usage-dd-eu.yaml' lname = os.path.abspath(os.path.dirname(__file__))+'/'+name if os.path.isfile(lname): with open(lname, 'r') as handle: items = yaml.load(handle) pump.update_detailed_usage(items) mocked.assert_called_once_with(items, 'dd-eu') print('***** Test update audit log ***') with mock.patch.object(influx, 'update_audit_log', return_value=None) as mocked: name = 'fixtures/audit-log-dd-eu.yaml' lname = os.path.abspath(os.path.dirname(__file__))+'/'+name if os.path.isfile(lname): with open(lname, 'r') as handle: items = yaml.load(handle) pump.update_audit_log(items) mocked.assert_called_once_with(items, 'dd-eu')
def test_mcp(self): pump = Pump() pump.set_endpoints() someday = date(2017, 03, 07) print('***** Test fetch summary usage ***') items = pump.fetch_summary_usage(on=someday) items.pop(0) name = 'fixtures/summary-usage-dd-eu.yaml' lname = os.path.abspath(os.path.dirname(__file__))+'/'+name if os.path.isfile(lname): with open(lname, 'r') as handle: expected = yaml.load(handle) self.assertEqual(items, expected) else: with open(lname, 'w') as handle: yaml.dump(items, handle) print('***** Test fetch detailed usage ***') items = pump.fetch_detailed_usage(on=someday) items.pop(0) name = 'fixtures/detailed-usage-dd-eu.yaml' lname = os.path.abspath(os.path.dirname(__file__))+'/'+name if os.path.isfile(lname): with open(lname, 'r') as handle: expected = yaml.load(handle) self.assertEqual(items[100:200], expected) else: with open(lname, 'w') as handle: yaml.dump(items[100:200], handle) print('***** Test pull ***') pump.pull(on=someday)