Beispiel #1
0
def test_representation_inconsistencies_should_not_matter():
    """Tests that loaded and collected timestamps can be compared, even if the internal
    and the persisted representations may differ between being tuples and lists.

    The internal representation was always with tuples, but the new JSON-based db
    persistence converts this to lists, since tuples don't exist in JSON.
    """
    ts = TimestampChecker(Mock(), Mock(), 'sometime')
    json_data = "[[1559907627.0, 28245286]]"
    ts.collected_times = ((1559907627.0, 28245286), )
    mock_info = Mock(value=json_data)
    with patch('nav.models.manage.NetboxInfo.objects.get',
               return_value=mock_info):
        yield ts.load()
        assert not ts.is_changed(max_deviation=60)
Beispiel #2
0
def test_is_changed(loaded, collected, max_deviation, expected, description):
    ts = TimestampChecker(Mock(), Mock(), 'sometime')
    ts.loaded_times = [loaded] if loaded else None
    ts.collected_times = [collected]
    assert ts.is_changed(max_deviation=max_deviation) == expected, description