Пример #1
0
 def test_acquire(self):
     with mock.patch.object(SourceProxy.SourceProxy, "__init__", lambda x, y: None):
         aws_occ = Occupancy.AWSOccupancy(config)
         with mock.patch.object(SourceProxy.SourceProxy, 'acquire') as acquire:
             acquire.return_value = account
             with mock.patch.object(boto3.session, 'Session') as s:
                 s.return_value = SessionMock()
                 with mock.patch.object(Occupancy.OccupancyForRegion, 'get_ec2_instances') as get_instances:
                     cap = utils.input_from_file(os.path.join(DATA_DIR,
                                                              'occupancy.fixture'))
                     get_instances.return_value = cap
                     res = aws_occ.acquire()
                     assert produces == list(res.keys())
                     df1 = expected_pandas_df.sort_values(
                         ['AvailabilityZone', 'InstanceType'])
                     new_df = res.get(produces[0]).sort_values(
                         ['AvailabilityZone', 'InstanceType'])
                     new_df.reindex()
                     assert utils.compare_dfs(df1, new_df)
 def test_produces(self):
     with mock.patch.object(SourceProxy.SourceProxy, "__init__",
                            lambda x, y: None):
         aws_occ = Occupancy.AWSOccupancy(config)
         assert aws_occ._produces == produces