Пример #1
0
    def test_increment_cache(self):
        """Sum our progress by increments properly."""
        expected = 25.0
        test_key = make_key('increment_test')
        increment = 25.0
        # Fresh increment, this initializes the value.
        increment_cache(test_key, increment)
        self.assertEqual(float(get_cache(test_key)['progress']), expected)

        # Increment an existing key
        increment_cache(test_key, increment)
        expected = 50.0
        self.assertEqual(float(get_cache(test_key)['progress']), expected)

        # This should put us well over 100.0 in incrementation w/o bounds check.
        for i in range(10):
            increment_cache(test_key, increment)

        expected = 100.0
        self.assertEqual(float(get_cache(test_key)['progress']), expected)
Пример #2
0
    def test_increment_cache(self):
        """Sum our progress by increments properly."""
        expected = 25.0
        test_key = make_key('increment_test')
        increment = 25.0
        # Fresh increment, this initializes the value.
        increment_cache(test_key, increment)
        self.assertEqual(float(get_cache(test_key)['progress']), expected)

        # Increment an existing key
        increment_cache(test_key, increment)
        expected = 50.0
        self.assertEqual(float(get_cache(test_key)['progress']), expected)

        # This should put us well over 100.0 in incrementation w/o bounds check.
        for i in range(10):
            increment_cache(test_key, increment)

        expected = 100.0
        self.assertEqual(float(get_cache(test_key)['progress']), expected)
Пример #3
0
def _get_cache_key(prefix, import_file_pk):
    """Makes a key like 'SEED:save_raw_data:LOCK:45'."""
    return make_key(
        '{0}:{1}'.format(prefix, import_file_pk)
    )
Пример #4
0
 def test_get_prog_key(self):
     """We format our cache key properly."""
     expected = make_key('SEED:fun_func:PROG:' + str(self.pk))
     self.assertEqual(decorators.get_prog_key('fun_func', self.pk),
                      expected)
Пример #5
0
def _get_cache_key(prefix, import_file_pk):
    """Makes a key like 'SEED:save_raw_data:LOCK:45'."""
    return make_key('{0}:{1}'.format(prefix, import_file_pk))
Пример #6
0
 def test_get_prog_key(self):
     """We format our cache key properly."""
     expected = make_key('SEED:fun_func:PROG:' + str(self.pk))
     self.assertEqual(decorators.get_prog_key('fun_func', self.pk),
                      expected)