Example #1
0
def increment_object_counter(node_uri, epoch_field, dry_run=False):
    """
    Increments the object counter for the given epoch/field on the specified
    node.

    Returns:
      new_count: str
        The object count AFTER incrementing.
    """
    current_count = read_object_counter(node_uri, epoch_field, dry_run=dry_run)

    if current_count is None:
        new_count = "01"
    else:
        new_count = coding.base36encode(coding.base36decode(current_count) + 1,
                                        pad_length=2)

    set_property(node_uri,
                 build_counter_tag(epoch_field, dry_run=dry_run),
                 new_count,
                 ossos_base=True)

    return new_count
Example #2
0
 def test_base36_encode_pad_long(self):
     assert_that(coding.base36encode(10000, pad_length=2), equal_to("7PS"))
Example #3
0
 def test_base36_encode_10000(self):
     assert_that(coding.base36encode(10000), equal_to("7PS"))
     assert_that(coding.base36decode("7PS"), equal_to(10000))
Example #4
0
 def test_base36_encode_pad_short(self):
     assert_that(coding.base36encode(1, pad_length=2), equal_to("01"))
Example #5
0
 def test_base36_encode_decode_1(self):
     assert_that(coding.base36encode(1), equal_to("1"))
     assert_that(coding.base36decode("1"), equal_to(1))