Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Teststruct improvement application #404

Closed
wants to merge 53 commits into from
Closed

Teststruct improvement application #404

wants to merge 53 commits into from

Conversation

erickvermot
Copy link
Contributor

@erickvermot erickvermot commented Jul 11, 2017

relates to #398
it applies the logic in #406

still needs to implement to v0x04

this needs:
#397
#403

@erickvermot erickvermot mentioned this pull request Jul 11, 2017
Copy link
Contributor

@diraol diraol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the comments I've made, please, review all changes considering the following:

To be in compliance with PEP8, when passing arguments to functions/methods or objects instantiations try filling out the line until the line width limit (79 characters).
Which means, avoid passing one argument per line. This syntax (one per line) is used when it is expected to have more items added to that "list".



class TestUBInt8(unittest.TestCase):
"""Test of UBInt8 BasicType."""
class TestUBInt8_(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this inherit from TestStructDump ?



class TestUBInt8(unittest.TestCase):
"""Test of UBInt8 BasicType."""
class TestUBInt8_(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why are you using an underscore on the end of the class name?

"""Basic test setup."""
self.ubint8 = basic_types.UBInt8()
dump = b'\xff'
obj = basic_types.UBInt32(2**8 - 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are testing the UBInt8 class, why are you using UBInt32 here?

def test_pack(self):
"""[Foundation/BasicTypes/UBInt8] - packing."""
pass
class TestUBInt16_(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this inherit from TestStructDump?



class TestUBInt16(unittest.TestCase):
"""Test of UBInt16 BasicType."""
class TestUBInt32_(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this inherit from TestStructDump?

super().set_minimum_size(16)
dumpfile = 'v0x01/ofpt_action_enqueue.dat'
obj = ActionEnqueue(port=Port.OFPP_CONTROLLER,
queue_id=4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for line break here.

super().set_minimum_size(8)
dumpfile = 'v0x01/ofpt_action_output.dat'
obj = ActionOutput(port=Port.OFPP_CONTROLLER,
max_length=8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for line break here

tp_dst=22)


class TestMatch_2(TestStructDump):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestMatch2

"""Each Header instantiations without xid should call randint."""
Header(), Header() # noqa
self.assertEqual(m.call_count, 2)
# @patch('pyof.v0x01.common.header.randint')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why leave it here commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it was meant for us to discuss during review. I did not understand this test.

def test_get_size(self):
"""[Common/PacketQueue] - size 8."""
self.assertEqual(self.message.get_size(), 8)
dump = b'\x00\x00\x00\x01\x00\x08\x00\x00' # needs to be checked
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No TODO comments, please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a TODO

@erickvermot
Copy link
Contributor Author

A few comments:

  • I'm waiting the review so I can apply the mods to v0x04 and completely remove the old method in this PR.
  • Tests classes will never be called directly by us, so I preferred the readability of TestHWAddress_random and TestHWAddress_mac then putting it all together.
    I did the mods anyway.
  • Many of the issues on the requested changes regarding line breaks a so were already there before this PR. If it is very important that we place it there, maybe we can open another issue with this purpose, and make PR fixing it everywhere in the code, otherwise we will just lose focus.

Apart from these little changes, anything important to point out about the proposed mods?

This was referenced Jul 13, 2017
@beraldoleal
Copy link
Member

Let's close this for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants