def test_main(scale_bigtable, get_cpu_load, sleep):
    SHORT_SLEEP = 5
    LONG_SLEEP = 10
    get_cpu_load.return_value = 0.5

    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_not_called()
    scale_bigtable.reset_mock()

    get_cpu_load.return_value = 0.7
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, True)
    scale_bigtable.reset_mock()

    get_cpu_load.return_value = 0.2
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, False)

    scale_bigtable.reset_mock()
def test_main(scale_bigtable, get_cpu_load, sleep):
    SHORT_SLEEP = 5
    LONG_SLEEP = 10
    get_cpu_load.return_value = 0.5

    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_not_called()
    scale_bigtable.reset_mock()

    get_cpu_load.return_value = 0.7
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, True)
    scale_bigtable.reset_mock()

    get_cpu_load.return_value = 0.2
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, False)

    scale_bigtable.reset_mock()
def test_main(scale_bigtable, get_cpu_load, get_storage_utilization, sleep):
    SHORT_SLEEP = 5
    LONG_SLEEP = 10

    # Test okay CPU, okay storage utilization
    get_cpu_load.return_value = 0.5
    get_storage_utilization.return_value = 0.5

    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, 0.6, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_not_called()
    scale_bigtable.reset_mock()

    # Test high CPU, okay storage utilization
    get_cpu_load.return_value = 0.7
    get_storage_utilization.return_value = 0.5
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, 0.6, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, True)
    scale_bigtable.reset_mock()

    # Test low CPU, okay storage utilization
    get_storage_utilization.return_value = 0.5
    get_cpu_load.return_value = 0.2
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, 0.6, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, False)
    scale_bigtable.reset_mock()

    # Test okay CPU, high storage utilization
    get_cpu_load.return_value = 0.5
    get_storage_utilization.return_value = 0.7

    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, 0.6, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, True)
    scale_bigtable.reset_mock()

    # Test high CPU, high storage utilization
    get_cpu_load.return_value = 0.7
    get_storage_utilization.return_value = 0.7
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, 0.6, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, True)
    scale_bigtable.reset_mock()

    # Test low CPU, high storage utilization
    get_cpu_load.return_value = 0.2
    get_storage_utilization.return_value = 0.7
    main(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, 0.6, 0.3, 0.6, SHORT_SLEEP,
         LONG_SLEEP)
    scale_bigtable.assert_called_once_with(BIGTABLE_INSTANCE,
                                           BIGTABLE_INSTANCE, True)
    scale_bigtable.reset_mock()