← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1526607] Re: refactor test_attributes.py

 

[Expired for neutron because there has been no activity for 60 days.]

** Changed in: neutron
       Status: Incomplete => Expired

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1526607

Title:
  refactor test_attributes.py

Status in neutron:
  Expired

Bug description:
  there're many test methods contains repeated test cases with the same
  pattern, such as

      def test_validate_string(self):
          msg = attributes._validate_string(None, None)
          self.assertEqual("'None' is not a valid string", msg)

          # 0 == len(data) == max_len
          msg = attributes._validate_string("", 0)
          self.assertIsNone(msg)

          # 0 == len(data) < max_len
          msg = attributes._validate_string("", 9)
          self.assertIsNone(msg)

          # 0 < len(data) < max_len
          msg = attributes._validate_string("123456789", 10)
          self.assertIsNone(msg)

          # 0 < len(data) == max_len
          msg = attributes._validate_string("123456789", 9)
          self.assertIsNone(msg)

          # 0 < max_len < len(data)
          msg = attributes._validate_string("1234567890", 9)
          self.assertEqual("'1234567890' exceeds maximum length of 9", msg)

          msg = attributes._validate_string("123456789", None)
          self.assertIsNone(msg)

  we can refactor this with a for loop, to make them look better.
  Following methods will be refactored:

  test_is_attr_set()
  test_validate_values()
  test_validate_not_empty_string_or_none()
  test_validate_string_or_none()
  test_validate_string()
  test_validate_list_of_unique_strings()
  test_validate_range()
  _test_validate_mac_address()
  test_validate_ip_address()
  test_validate_ip_address_bsd()
  test_validate_ip_address_or_none()
  test_uuid_pattern()
  test_mac_pattern()
  _test_validate_subnet()
  _test_validate_regex()
  test_validate_dict_without_constraints()
  test_validate_dict_or_empty()
  test_convert_to_int_int()
  test_convert_to_int_if_not_none()
  test_convert_to_int_str()
  test_convert_to_float_positve_value()
  test_convert_to_float_string()

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1526607/+subscriptions


References