class TestSession(unittest.TestCase): @mock.patch("ocr.persistence.create_engine") @mock.patch("ocr.persistence.sessionmaker") def config(self, mock_sessionmaker, mock_create_engine): self.mock_sessionmaker = mock_sessionmaker self.mock_create_engine = mock_create_engine self.mock_create_engine.return_value = "engine" self.mock_session = mock.Mock() self.mock_session.return_value = "session" self.mock_sessionmaker.return_value = self.mock_session self.session = Session() def setUp(self): self.mock_sessionmaker = None self.mock_create_engine = None self.mock_session = None self.session = None self.config() def test___init__(self): self.mock_create_engine.assert_called_with( 'mysql+pymysql://%s:%s@%s/%s' % (BD_USER, BD_PASSWORD, BD_HOST, BD_NAME), pool_recycle=7200, encoding='utf8', pool_size=100) self.mock_sessionmaker.assert_called_with(bind="engine") def test_get_session(self): self.assertEqual("session", self.session.get_session()) def test_get_engine(self): self.assertEqual("engine", self.session.get_engine())
class TestSession(unittest.TestCase): @mock.patch("ocr.persistence.create_engine") @mock.patch("ocr.persistence.sessionmaker") def config(self, mock_sessionmaker, mock_create_engine): self.mock_sessionmaker = mock_sessionmaker self.mock_create_engine = mock_create_engine self.mock_create_engine.return_value = "engine" self.mock_session = mock.Mock() self.mock_session.return_value = "session" self.mock_sessionmaker.return_value = self.mock_session self.session = Session() def setUp(self): self.mock_sessionmaker = None self.mock_create_engine = None self.mock_session = None self.session = None self.config() def test___init__(self): self.mock_create_engine.assert_called_with('mysql+pymysql://%s:%s@%s/%s' % (BD_USER, BD_PASSWORD, BD_HOST, BD_NAME), pool_recycle=7200, encoding='utf8', pool_size=100) self.mock_sessionmaker.assert_called_with(bind="engine") def test_get_session(self): self.assertEqual("session", self.session.get_session()) def test_get_engine(self): self.assertEqual("engine", self.session.get_engine())
def config(self, mock_sessionmaker, mock_create_engine): self.mock_sessionmaker = mock_sessionmaker self.mock_create_engine = mock_create_engine self.mock_create_engine.return_value = "engine" self.mock_session = mock.Mock() self.mock_session.return_value = "session" self.mock_sessionmaker.return_value = self.mock_session self.session = Session()
def main(): parser = argparse.ArgumentParser(description='Delete ong in the system.') parser.add_argument('name', help='Name of ong') args = parser.parse_args() name = args.name session = Session() o = Ong(session=session.get_session(), name=name) o.delete()
def main(): parser = argparse.ArgumentParser(description="Add new ong in the system.") parser.add_argument("name", help="Name of new ong") parser.add_argument("-H", "--homepage", metavar="URL", nargs="?", help="URL for ong homepage", default="#") parser.add_argument("-N", "--completename", metavar="CNAME", nargs="?", help="Complete name of new ong") args = parser.parse_args() name = args.name session = Session() o = Ong(session=session.get_session(), name=name) return o.save()
def main(): parser = argparse.ArgumentParser(description='Add new ong in the system.') parser.add_argument('name', help='Name of new ong') parser.add_argument('-H', '--homepage', metavar='URL', nargs='?', help='URL for ong homepage', default='#') parser.add_argument('-N', '--completename', metavar='CNAME', nargs='?', help='Complete name of new ong') args = parser.parse_args() name = args.name session = Session() o = Ong(session=session.get_session(), name=name) return o.save()