本文整理汇总了Python中arctic.arctic.ArcticLibraryBinding类的典型用法代码示例。如果您正苦于以下问题:Python ArcticLibraryBinding类的具体用法?Python ArcticLibraryBinding怎么用?Python ArcticLibraryBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArcticLibraryBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_quota_Zero2
def test_check_quota_Zero2():
m = Mock(spec=ArcticLibraryBinding)
m.quota = None
m.get_library_metadata.return_value = 0
ArcticLibraryBinding.check_quota(m)
m.get_library_metadata.assert_called_once_with('QUOTA')
assert m.quota == 0
示例2: test_check_quota_Zero2
def test_check_quota_Zero2():
self = create_autospec(ArcticLibraryBinding)
self.quota = None
self.get_library_metadata.return_value = 0
ArcticLibraryBinding.check_quota(self)
self.get_library_metadata.assert_called_once_with('QUOTA')
assert self.quota == 0
示例3: test_check_quota_exceeded
def test_check_quota_exceeded():
self = create_autospec(ArcticLibraryBinding)
self.arctic = create_autospec(Arctic)
self.quota = 1024 * 1024 * 1024
self.quota_countdown = 0
self.arctic.__getitem__.return_value = Mock(
stats=Mock(return_value={"totals": {"size": 1024 * 1024 * 1024, "count": 100}})
)
with pytest.raises(QuotaExceededException) as e:
ArcticLibraryBinding.check_quota(self)
assert "Quota Exceeded: 1.000 / 1 GB used" in str(e)
示例4: test_check_quota_exceeded
def test_check_quota_exceeded():
self = create_autospec(ArcticLibraryBinding)
self.arctic = create_autospec(Arctic)
self.get_library_metadata.return_value = 1024 * 1024 * 1024
self.quota_countdown = 0
self.arctic.__getitem__.return_value = Mock(stats=Mock(return_value={'totals':
{'size': 1024 * 1024 * 1024,
'count': 100,
}
}))
with pytest.raises(QuotaExceededException) as e:
ArcticLibraryBinding.check_quota(self)
assert "Quota Exceeded: 1.000 / 1 GB used" in str(e)
示例5: test_check_quota_info
def test_check_quota_info():
self = create_autospec(ArcticLibraryBinding)
self.arctic = create_autospec(Arctic)
self.quota = 1024 * 1024 * 1024
self.quota_countdown = 0
self.arctic.__getitem__.return_value = Mock(
stats=Mock(return_value={"totals": {"size": 1 * 1024 * 1024, "count": 100}})
)
with patch("arctic.arctic.logger.info") as info:
ArcticLibraryBinding.check_quota(self)
self.arctic.__getitem__.assert_called_once_with(self.get_name.return_value)
info.assert_called_once_with("Mongo Quota: 0.001 / 1 GB used")
assert self.quota_countdown == 51153
示例6: test_check_quota_90_percent
def test_check_quota_90_percent():
self = create_autospec(ArcticLibraryBinding, database_name='arctic_db',
library='lib')
self.arctic = create_autospec(Arctic)
self.get_library_metadata.return_value = 1024 * 1024 * 1024
self.quota_countdown = 0
self.arctic.__getitem__.return_value = Mock(stats=Mock(return_value={'totals':
{'size': 0.91 * 1024 * 1024 * 1024,
'count': 1000000,
}
}))
with patch('arctic.arctic.logger.warning') as warn:
ArcticLibraryBinding.check_quota(self)
self.arctic.__getitem__.assert_called_once_with(self.get_name.return_value)
warn.assert_called_once_with('Mongo Quota: arctic_db.lib 0.910 / 1 GB used')
示例7: test_check_quota
def test_check_quota():
self = create_autospec(ArcticLibraryBinding)
self.arctic = create_autospec(Arctic)
self.quota = 1024 * 1024 * 1024
self.quota_countdown = 0
self.arctic.__getitem__.return_value = Mock(stats=Mock(return_value={'totals':
{'size': 900 * 1024 * 1024,
'count': 100,
}
}))
with patch('arctic.arctic.logger.warn') as warn:
ArcticLibraryBinding.check_quota(self)
self.arctic.__getitem__.assert_called_once_with(self.get_name.return_value)
warn.assert_called_once_with('Mongo Quota: 0.879 / 1 GB used')
assert self.quota_countdown == 6
示例8: test_check_quota_info
def test_check_quota_info():
self = create_autospec(ArcticLibraryBinding)
self.arctic = create_autospec(Arctic)
self.get_library_metadata.return_value = 1024 * 1024 * 1024
self.quota_countdown = 0
self.arctic.__getitem__.return_value = Mock(stats=Mock(return_value={'totals':
{'size': 1 * 1024 * 1024,
'count': 100,
}
}))
with patch('arctic.arctic.logger.info') as info:
ArcticLibraryBinding.check_quota(self)
self.arctic.__getitem__.assert_called_once_with(self.get_name.return_value)
info.assert_called_once_with('Mongo Quota: 0.001 / 1 GB used')
assert self.quota_countdown == 51153
示例9: test_check_quota_countdown
def test_check_quota_countdown():
self = create_autospec(ArcticLibraryBinding)
self.get_library_metadata.return_value = 10
self.quota_countdown = 10
ArcticLibraryBinding.check_quota(self)
assert self.quota_countdown == 9
示例10: test_get_quota
def test_get_quota():
m = Mock(spec=ArcticLibraryBinding)
m.get_library_metadata.return_value = 42
assert ArcticLibraryBinding.get_quota(m) == 42
m.get_library_metadata.assert_called_once_with('QUOTA')
示例11: test_set_quota
def test_set_quota():
m = Mock(spec=ArcticLibraryBinding)
ArcticLibraryBinding.set_quota(m, 10000)
m.set_library_metadata.assert_called_once_with('QUOTA', 10000)
assert m.quota_countdown == 0
assert m.quota == 10000
示例12: test_check_quota_countdown
def test_check_quota_countdown():
self = create_autospec(ArcticLibraryBinding)
self.quota = 10
self.quota_countdown = 10
ArcticLibraryBinding.check_quota(self)
assert self.quota_countdown == 9
示例13: test_check_quota_Zero
def test_check_quota_Zero():
self = create_autospec(ArcticLibraryBinding)
self.quota = 0
ArcticLibraryBinding.check_quota(self)
示例14: test_get_quota
def test_get_quota():
self = create_autospec(ArcticLibraryBinding)
self.get_library_metadata.return_value = 42
assert ArcticLibraryBinding.get_quota(self) == 42
self.get_library_metadata.assert_called_once_with('QUOTA')
示例15: test_set_quota
def test_set_quota():
self = create_autospec(ArcticLibraryBinding)
ArcticLibraryBinding.set_quota(self, 10000)
self.set_library_metadata.assert_called_once_with('QUOTA', 10000)
assert self.quota_countdown == 0
assert self.quota == 10000