Consider the following code:
class Foo:
@staticmethod
def is_room_member(invitee, msg):
return invitee in msg.frm.room.occupants
I want to test the method is_room_member where invitee is a string and
occupants is a list of string.
If invitee = 'batman' and occupants = ['batman', 'superman'] the method is_room_member returns True.
msg is the object which needs to be mocked so that I can test this method.
How can I test this method, since it'll require this msg object which has nested attributes?
I want the test to be something like:
class Testing(unittest.TestCase):
def test_is_room_member(self):
occupants = ['batman', 'superman']
# mocking
# msg = MagicMock()
# msg.frm.room.occupants = occupants
self.assertTrue(Foo.is_room_member('batman', msg))