# Path: mom/builtins.py
# def byte(number):
# def bytes_leading(raw_bytes, needle=_compat.ZERO_BYTE):
# def bytes_trailing(raw_bytes, needle=_compat.ZERO_BYTE):
# def bin(number, prefix="0b"):
# def hex(number, prefix="0x"):
# def is_sequence(obj):
# def is_unicode(obj):
# def is_bytes(obj):
# def is_bytes_or_unicode(obj):
# def is_integer(obj):
# def integer_byte_length(number):
# def integer_byte_size(number):
# def integer_bit_length(number):
# def integer_bit_size(number):
# def integer_bit_count(number):
# def is_even(num):
# def is_odd(num):
# def is_positive(num):
# def is_negative(num):
# 
# Path: mom/codec/integer.py
# ZERO_BYTE = _compat.ZERO_BYTE
# EMPTY_BYTE = _compat.EMPTY_BYTE
# def bytes_to_uint(raw_bytes):
# def uint_to_bytes(number, fill_size=0, chunk_size=0, overflow=False):
# 
# Path: mom/security/random.py
# HEXADECIMAL_DIGITS = string.DIGITS + "abcdef"
# DIGITS = string.DIGITS
# LOWERCASE_ALPHA = string.ASCII_LOWERCASE
# UPPERCASE_ALPHA = string.ASCII_UPPERCASE
# LOWERCASE_ALPHANUMERIC = LOWERCASE_ALPHA + string.DIGITS
# UPPERCASE_ALPHANUMERIC = UPPERCASE_ALPHA + string.DIGITS
# ALPHA = string.ASCII_LETTERS
# ALPHANUMERIC = ALPHA + string.DIGITS
# ASCII_PRINTABLE = ALPHA + string.DIGITS + string.PUNCTUATION
# ALL_PRINTABLE = string.PRINTABLE
# PUNCTUATION = string.PUNCTUATION
# def generate_random_bits(n_bits, rand_func=generate_random_bytes):
# def generate_random_uint_atmost(n_bits, rand_func=generate_random_bytes):
# def generate_random_uint_exactly(n_bits, rand_func=generate_random_bytes):
# def generate_random_uint_between(low, high, rand_func=generate_random_bytes):
# def generate_random_hex_string(length=8, rand_func=generate_random_bytes):
# def random_choice(sequence, rand_func=generate_random_bytes):
# def random_shuffle(sequence, rand_func=generate_random_bytes):
# def generate_random_sequence(length, pool, rand_func=generate_random_bytes):
# def generate_random_string(length, pool=ALPHANUMERIC,
#                            rand_func=generate_random_bytes):
# def calculate_entropy(length, pool=ALPHANUMERIC):
# def generate_random_sequence_strong(entropy, pool,
#                                     rand_func=generate_random_bytes):
# def generate_random_password(entropy, pool=ASCII_PRINTABLE,
#                              rand_func=generate_random_bytes):


import unittest2
from mom import builtins
from mom.codec import integer
from mom.security import random
  def test_0_1(self):
    self.assertEqual(random.generate_random_uint_between(0, 1), 0)

  def test_range(self):
    low, high = 1, 10
    for _ in range(1000):
      value = random.generate_random_uint_between(low, high)
      self.assertTrue(value >= low and value < high)

  def test_ValueError_when_low_greater_than_high(self):
    low, high = 4, 3
    self.assertRaises(ValueError, random.generate_random_uint_between, low, high)

  def test_TypeError_when_invalid_argument(self):
    self.assertRaises(TypeError, random.generate_random_uint_between, None, None)
    self.assertRaises(TypeError, random.generate_random_uint_between, {}, {})
    self.assertRaises(TypeError,
                      random.generate_random_uint_between, object, object)
    self.assertRaises(TypeError, random.generate_random_uint_between, True, True)
    self.assertRaises(TypeError, random.generate_random_uint_between, "", "")


class Test_generate_random_string(unittest2.TestCase):
  def test_random_string_length(self):
    for _ in range(10):
      self.assertEqual(len(random.generate_random_string(64)),
                       len(random.generate_random_string(64)))
      self.assertEqual(len(random.generate_random_string(64)), 64)

  def test_is_string(self):

# Path: mom/builtins.py
# def byte(number):
# def bytes_leading(raw_bytes, needle=_compat.ZERO_BYTE):
# def bytes_trailing(raw_bytes, needle=_compat.ZERO_BYTE):
# def bin(number, prefix="0b"):
# def hex(number, prefix="0x"):
# def is_sequence(obj):
# def is_unicode(obj):
# def is_bytes(obj):
# def is_bytes_or_unicode(obj):
# def is_integer(obj):
# def integer_byte_length(number):
# def integer_byte_size(number):
# def integer_bit_length(number):
# def integer_bit_size(number):
# def integer_bit_count(number):
# def is_even(num):
# def is_odd(num):
# def is_positive(num):
# def is_negative(num):
# 
# Path: mom/codec/integer.py
# ZERO_BYTE = _compat.ZERO_BYTE
# EMPTY_BYTE = _compat.EMPTY_BYTE
# def bytes_to_uint(raw_bytes):
# def uint_to_bytes(number, fill_size=0, chunk_size=0, overflow=False):
# 
# Path: mom/security/random.py
# HEXADECIMAL_DIGITS = string.DIGITS + "abcdef"
# DIGITS = string.DIGITS
# LOWERCASE_ALPHA = string.ASCII_LOWERCASE
# UPPERCASE_ALPHA = string.ASCII_UPPERCASE
# LOWERCASE_ALPHANUMERIC = LOWERCASE_ALPHA + string.DIGITS
# UPPERCASE_ALPHANUMERIC = UPPERCASE_ALPHA + string.DIGITS
# ALPHA = string.ASCII_LETTERS
# ALPHANUMERIC = ALPHA + string.DIGITS
# ASCII_PRINTABLE = ALPHA + string.DIGITS + string.PUNCTUATION
# ALL_PRINTABLE = string.PRINTABLE
# PUNCTUATION = string.PUNCTUATION
# def generate_random_bits(n_bits, rand_func=generate_random_bytes):
# def generate_random_uint_atmost(n_bits, rand_func=generate_random_bytes):
# def generate_random_uint_exactly(n_bits, rand_func=generate_random_bytes):
# def generate_random_uint_between(low, high, rand_func=generate_random_bytes):
# def generate_random_hex_string(length=8, rand_func=generate_random_bytes):
# def random_choice(sequence, rand_func=generate_random_bytes):
# def random_shuffle(sequence, rand_func=generate_random_bytes):
# def generate_random_sequence(length, pool, rand_func=generate_random_bytes):
# def generate_random_string(length, pool=ALPHANUMERIC,
#                            rand_func=generate_random_bytes):
# def calculate_entropy(length, pool=ALPHANUMERIC):
# def generate_random_sequence_strong(entropy, pool,
#                                     rand_func=generate_random_bytes):
# def generate_random_password(entropy, pool=ASCII_PRINTABLE,
#                              rand_func=generate_random_bytes):


# Path: mom/tests/test_mom_security_random.py
import unittest2
from mom import builtins
from mom.codec import integer
from mom.security import random

  def test_0_1(self):
    self.assertEqual(random.generate_random_uint_between(0, 1), 0)

  def test_range(self):
    low, high = 1, 10
    for _ in range(1000):
      value = random.generate_random_uint_between(low, high)
      self.assertTrue(value >= low and value < high)

  def test_ValueError_when_low_greater_than_high(self):
    low, high = 4, 3
    self.assertRaises(ValueError, random.generate_random_uint_between, low, high)

  def test_TypeError_when_invalid_argument(self):
    self.assertRaises(TypeError, random.generate_random_uint_between, None, None)
    self.assertRaises(TypeError, random.generate_random_uint_between, {}, {})
    self.assertRaises(TypeError,
                      random.generate_random_uint_between, object, object)
    self.assertRaises(TypeError, random.generate_random_uint_between, True, True)
    self.assertRaises(TypeError, random.generate_random_uint_between, "", "")


class Test_generate_random_string(unittest2.TestCase):
  def test_random_string_length(self):
    for _ in range(10):
      self.assertEqual(len(random.generate_random_string(64)),
                       len(random.generate_random_string(64)))
      self.assertEqual(len(random.generate_random_string(64)), 64)

  def test_is_string(self):

    self.assertTrue(builtins.is_bytes_or_unicode(random.generate_random_string(64)))