Beispiel #1
0
def payday():

    # Wire things up.
    # ===============
    # Manually override max db connections so that we only have one connection.
    # Our db access is serialized right now anyway, and with only one
    # connection it's easier to trust changes to statement_timeout. The point
    # here is that we want to turn off statement_timeout for payday.

    env = wireup.env()
    env.database_maxconn = 1
    db = wireup.db(env)
    db.run("SET statement_timeout = 0")

    wireup.billing(env)
    wireup.nanswers(env)


    # Lazily import the billing module.
    # =================================
    # This dodges a problem where db in billing is None if we import it from
    # gittip before calling wireup.billing.

    from gittip.billing.payday import Payday

    try:
        Payday(db).run()
    except KeyboardInterrupt:
        pass
    except:
        import aspen
        import traceback
        aspen.log(traceback.format_exc())
Beispiel #2
0
def payday():

    # Wire things up.
    # ===============

    env = wireup.env()
    db = wireup.db(env)

    wireup.billing(env)
    wireup.nanswers(env)


    # Lazily import the billing module.
    # =================================
    # This dodges a problem where db in billing is None if we import it from
    # gittip before calling wireup.billing.

    from gittip.billing.exchanges import sync_with_balanced
    from gittip.billing.payday import Payday

    try:
        with db.get_cursor() as cursor:
            sync_with_balanced(cursor)
        Payday.start().run()
    except KeyboardInterrupt:
        pass
    except:
        import aspen
        import traceback
        aspen.log(traceback.format_exc())
Beispiel #3
0
    def test_stats_description_accurate_outside_of_payday(self, mock_datetime):
        """Test stats page outside of the payday running"""
        self.clear_paydays()
        a_monday = datetime(2012, 8, 6, 12, 00, 01)
        mock_datetime.utcnow.return_value = a_monday

        db = wireup.db()
        wireup.billing()
        pd = Payday(db)
        pd.start()

        body = self.get_stats_page()
        self.assertTrue("is ready for <b>this Friday</b>" in body)
        pd.end()
Beispiel #4
0
    def test_stats_description_accurate_during_payday_run(self, mock_datetime):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/gittip/www.gittip.com/issues/92.
        """
        a_thursday = datetime(2012, 8, 9, 11, 00, 01)
        mock_datetime.utcnow.return_value = a_thursday

        wireup.billing()
        payday = Payday(self.postgres)
        payday.start()

        body = self.get_stats_page()
        assert "is changing hands <b>right now!</b>" in body, body
        payday.end()
    def test_stats_description_accurate_during_payday_run(self, mock_datetime):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/gittip/www.gittip.com/issues/92.
        """
        a_thursday = datetime(2012, 8, 9, 11, 00, 01)
        mock_datetime.utcnow.return_value = a_thursday

        wireup.billing()
        payday = Payday(self.postgres)
        payday.start()

        body = self.get_stats_page()
        assert "is changing hands <b>right now!</b>" in body, body
        payday.end()
Beispiel #6
0
def test_stats_description_accurate_during_payday_run(mock_datetime):
    """Test that stats page takes running payday into account.

    This test was originally written to expose the fix required for
    https://github.com/whit537/www.gittip.com/issues/92.
    """
    with testing.load() as context:
        a_thursday = datetime(2012, 8, 9, 12, 00, 01)
        mock_datetime.utcnow.return_value = a_thursday

        wireup.billing()
        pd = Payday(context.db)
        pd.start()

        body = get_stats_page()
        assert "is changing hands <b>right now!</b>" in body, body
        pd.end()
Beispiel #7
0
    def test_stats_description_accurate_during_payday_run(self, mock_datetime):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/whit537/www.gittip.com/issues/92.
        """
        self.clear_paydays()
        a_friday = datetime(2012, 8, 10, 12, 00, 01)
        mock_datetime.utcnow.return_value = a_friday

        db = wireup.db()
        wireup.billing()
        pd = Payday(db)
        pd.start()

        body = self.get_stats_page()
        self.assertTrue("is changing hands <b>right now!</b>" in body)
        pd.end()
    def test_stats_description_accurate_during_payday_run(self, utcnow):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/gittip/www.gittip.com/issues/92.
        """
        a_thursday = DateTime(2012, 8, 9, 11, 00, 01)
        utcnow.return_value = a_thursday

        self.client.hydrate_website()

        env = wireup.env()
        wireup.billing(env)
        payday = Payday.start()

        body = self.get_stats_page()
        assert "is changing hands <b>right now!</b>" in body, body
        payday.end()
Beispiel #9
0
def payday():
    db = wireup.db()
    wireup.billing()

    # Lazily import the billing module.
    # =================================
    # This dodges a problem where db in billing is None if we import it from
    # gittip before calling wireup.billing.

    from gittip.billing.payday import Payday

    try:
        Payday(db).run()
    except KeyboardInterrupt:
        pass
    except:
        import aspen
        import traceback
        aspen.log(traceback.format_exc())
Beispiel #10
0
    def test_stats_description_accurate_during_payday_run(self, utcnow):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/gittip/www.gittip.com/issues/92.
        """
        a_thursday = DateTime(2012, 8, 9, 11, 00, 01)
        utcnow.return_value = a_thursday

        self.client.hydrate_website()

        env = wireup.env()
        wireup.billing(env)
        payday = Payday(self.db)
        payday.start()

        body = self.get_stats_page()
        assert "is changing hands <b>right now!</b>" in body, body
        payday.end()
Beispiel #11
0
def payday():
    db = wireup.db()
    wireup.billing()


    # Lazily import the billing module.
    # =================================
    # This dodges a problem where db in billing is None if we import it from
    # gittip before calling wire_samurai.

    from gittip.billing.payday import Payday

    try:
        Payday(db).run()
    except KeyboardInterrupt:
        pass
    except:
        import aspen
        import traceback
        aspen.log(traceback.format_exc())
Beispiel #12
0
    def test_stats_description_accurate_during_payday_run(self):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/gittip/www.gittip.com/issues/92.
        """

        # Hydrating a website requires a functioning datetime module.
        self.client.hydrate_website()

        a_thursday = datetime.datetime(2012, 8, 9, 11, 00, 01)
        with patch.object(datetime, 'datetime') as mock_datetime:
            mock_datetime.utcnow.return_value = a_thursday

            wireup.billing()
            payday = Payday(self.db)
            payday.start()

            body = self.get_stats_page()
            assert "is changing hands <b>right now!</b>" in body, body
            payday.end()
Beispiel #13
0
    def test_stats_description_accurate_during_payday_run(self):
        """Test that stats page takes running payday into account.

        This test was originally written to expose the fix required for
        https://github.com/gittip/www.gittip.com/issues/92.
        """

        # Hydrating a website requires a functioning datetime module.
        self.client.hydrate_website()

        a_thursday = datetime.datetime(2012, 8, 9, 11, 00, 01)
        with patch.object(datetime, 'datetime') as mock_datetime:
            mock_datetime.utcnow.return_value = a_thursday

            wireup.billing()
            payday = Payday(self.db)
            payday.start()

            body = self.get_stats_page()
            assert "is changing hands <b>right now!</b>" in body, body
            payday.end()
Beispiel #14
0
def payday():
    wireup.db()
    wireup.billing()

    # Lazily import the billing module.
    # =================================
    # This dodges a problem where db in billing is None if we import it from
    # gittip before calling wire_samurai, and it also dodges:
    #
    #   https://github.com/FeeFighters/samurai-client-python/issues/8

    from gittip import billing

    try:
        billing.payday()
    except KeyboardInterrupt:
        pass
    except:
        import aspen
        import traceback

        aspen.log(traceback.format_exc())
#!./env/bin/python
"""This is a workaround for https://github.com/balanced/balanced-api/issues/141

Usage (tested on Mac OS):

    [gittip] $ open `heroku config | swaddle - ./find-in-balanced-by-username.py foobar 2> /dev/null`

The script will search for the user and print out the URI of their page in the
Balanced dashboard, and open will open it in your default web browser.

"""
import sys

import balanced
from gittip import wireup

wireup.billing()

email_address = sys.argv[1] + "@gittip.com"  # hack into an email address
api_uri = balanced.Account.query.filter(email_address=email_address).one().uri
dashboard_uri = "https://www.balancedpayments.com/" + api_uri[4:]
print dashboard_uri
 def __init__(self):
     self.db = wireup.db()
     self.billing = wireup.billing()
     self._delete_data()
#!./env/bin/python
"""This is a workaround for https://github.com/balanced/balanced-api/issues/141

Usage (tested on Mac OS):

    [gittip] $ open `heroku config | swaddle - ./find-in-balanced-by-username.py foobar 2> /dev/null`

The script will search for the user and print out the URI of their page in the
Balanced dashboard, and open will open it in your default web browser.

"""
import sys

import balanced
from gittip import wireup


wireup.billing()


email_address = sys.argv[1] + "@gittip.com"  # hack into an email address
api_uri = balanced.Account.query.filter(email_address=email_address).one().uri
dashboard_uri = "https://www.balancedpayments.com/" + api_uri[4:]
print dashboard_uri
 def __init__(self):
     self.db = wireup.db()
     self.billing = wireup.billing()
     self._delete_data()