← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1526607] [NEW] refactor test_attributes.py

 

Public bug reported:

there're many test methods contains repeated test cases, 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

** Affects: neutron
     Importance: Undecided
     Assignee: Bo Chi (bochi-michael)
         Status: New

** Changed in: neutron
     Assignee: (unassigned) => Bo Chi (bochi-michael)

-- 
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:
  New

Bug description:
  there're many test methods contains repeated test cases, 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

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


Follow ups