def test_add_new_user(self): d = StubDataDriver() d.set_file_exists(False) p = Passwd(name="test.txt", driver=d) p.add_user("admin", "admin") p.commit() self.assertEqual(d.get_text(), "admin;admin\n")
def test_add_existing_user(self): d = StubDataDriver() d.set_file_exists(True) d.set_text("a;a\nb;b\nc;c\n") p = Passwd(name="test.txt", driver=d) try: p.add_user("c", "c") except RuntimeError: self.assertEqual(True, True) return self.assertEqual(True, False)