Ejemplo n.º 1
0
 def setUp(self):
     engine.save(AppDetails(100000001, 'us', {
         'price': 1.50,
         'currency': 'USD'
     }),
                 overwrite=True)
     engine.save(AppDetails(100000002, 'us', {
         'price': 5.00,
         'currency': 'USD'
     }),
                 overwrite=True)
     engine.save(AppDetails(100000003, 'us', {
         'price': 3.50,
         'currency': 'USD'
     }),
                 overwrite=True)
     engine.save(AppDetails(100000004, 'us', {
         'price': 1.25,
         'currency': 'USD'
     }),
                 overwrite=True)
     engine.save(AppDetails(100000005, 'us', {
         'price': 0,
         'currency': 'USD'
     }),
                 overwrite=True)
Ejemplo n.º 2
0
 def test_save(self):
     app_id = 100
     country = 'in'
     app_details = AppDetails(app_id, country)
     engine.save(app_details, overwrite=True)
     engine.delete_key(AppDetails, app_id=app_id, country=country)
     app_details = engine.get(AppDetails, app_id=app_id, country=country)
     self.assertIsNone(app_details)
Ejemplo n.º 3
0
 def test_save(self):
     app_id = 100
     country = 'in'
     app_details = AppDetails(app_id, country)
     engine.save(app_details, overwrite=True)
     engine.delete_key(AppDetails, app_id=app_id, country=country)
     app_details = engine.get(AppDetails, app_id=app_id, country=country)
     self.assertIsNone(app_details)
Ejemplo n.º 4
0
def load_app_details(app_ids, countries):
    """
    Queries external app store API for avaliable data for each
    app_id/countries combination.
    If data found, saves details in the AppDetails table.
    """
    for app_id in app_ids:
        for country in countries:
            data = get_app_data(app_id, country)
            if not data:
                continue
            app_details = AppDetails(app_id, country, data=data)
            engine.save(app_details)
Ejemplo n.º 5
0
def load_app_details(app_ids, countries):
    """
    Queries external app store API for avaliable data for each
    app_id/countries combination.
    If data found, saves details in the AppDetails table.
    """
    for app_id in app_ids:
        for country in countries:
            data = get_app_data(app_id, country)
            if not data:
                continue
            app_details = AppDetails(app_id, country, data=data)
            engine.save(app_details)
Ejemplo n.º 6
0
 def setUp(self):
     engine.save(AppDetails(
         100000001, 'us', {'price': 1.50, 'currency': 'USD'}),
         overwrite=True)
     engine.save(AppDetails(
         100000002, 'us', {'price': 5.00, 'currency': 'USD'}),
         overwrite=True)
     engine.save(AppDetails(
         100000003, 'us', {'price': 3.50, 'currency': 'USD'}),
         overwrite=True)
     engine.save(AppDetails(
         100000004, 'us', {'price': 1.25, 'currency': 'USD'}),
         overwrite=True)
     engine.save(AppDetails(
         100000005, 'us', {'price': 0, 'currency': 'USD'}),
         overwrite=True)
Ejemplo n.º 7
0
import uuid
from models import engine, Account, Tweet


account = Account(
    id=uuid.uuid4(), name='@garybernhardt',
    email='REDACTED')
# This save will raise if the account id is already taken
unique_id = Account.id.is_(None)
engine.save(account, condition=unique_id)

account.name = 'garybernhardt'
del account.email
engine.save(account)

tweet = Tweet(
    account=account.id, id='616102582239399936',
    content='today, I wrote a type validator in Python, as you do',
    favorites=9)

engine.save([account, tweet])

# Don't delete the tweet if it's been
# favorited enough for people to notice
not_popular = Tweet.favorites < 10
engine.delete(tweet, condition=not_popular)

same_account = Tweet.account == tweet.account
same_id = Tweet.id == tweet.id
same_content = Tweet.content == tweet.content
Ejemplo n.º 8
0
import uuid
from models import engine, Account, Tweet

account = Account(id=uuid.uuid4(), name='@garybernhardt', email='REDACTED')
# This save will raise if the account id is already taken
unique_id = Account.id.is_(None)
engine.save(account, condition=unique_id)

account.name = 'garybernhardt'
del account.email
engine.save(account)

tweet = Tweet(account=account.id,
              id='616102582239399936',
              content='today, I wrote a type validator in Python, as you do',
              favorites=9)

engine.save([account, tweet])

# Don't delete the tweet if it's been
# favorited enough for people to notice
not_popular = Tweet.favorites < 10
engine.delete(tweet, condition=not_popular)

same_account = Tweet.account == tweet.account
same_id = Tweet.id == tweet.id
same_content = Tweet.content == tweet.content

same_tweet = same_account & same_id & same_content
engine.save(tweet, condition=same_tweet)