Page MenuHomePhabricator
Paste P16340

(An Untitled Masterwork)
ActivePublic

Authored by jbond on Wed, Jun 9, 11:23 AM.
""" Testing using
$ python3 -m unittest wmflib/tests/unit/test_idm.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.003s
OK
"""
import argparse
from argparse import Namespace
from unittest import TestCase
from unittest.mock import patch
from wmflib.idm import logoutd_args, LogoutdBase
# This one dosn;t seem to be in the output
@patch('argparse._sys.argv', ['script', 'logout'])
def test_logoutd_args():
args = logoutd_args('foo')
assert args == Namespace(command='logout')
class TestIDM(TestCase):
# The ones defined here seem to work
@patch("wmflib.idm.LogoutdBase.__abstractmethods__", set())
@patch('argparse.ArgumentParser.parse_args', return_value=Namespace(uid='bob', cn='Bob'))
def test_initialization(self, mock_args):
test_idm = LogoutdBase()
assert test_idm.user == 'Bob'
test_idm.user_identifier = 'uid'
assert test_idm.user == 'bob'
@patch("wmflib.idm.LogoutdBase.__abstractmethods__", set())
@patch('argparse.ArgumentParser.parse_args', return_value=Namespace(uid='bob', cn='Bob'))
def test_user_itendifier_uid(self, mock_args):
test_idm = LogoutdBase()
test_idm.user_identifier = 'uid'
assert test_idm.user == 'bob'

Event Timeline

jbond updated the paste's language from autodetect to python.Wed, Jun 9, 11:26 AM
jbond edited the content of this paste. (Show Details)