Fixing tests after rebase
parent
d599fb9540
commit
a90833f178
|
@ -13,8 +13,8 @@ class DeviceSubscriptionEndpoint(SeleneEndpoint):
|
|||
with get_db_connection(self.config['DB_CONNECTION_POOL']) as db:
|
||||
account = AccountRepository(db).get_account_by_device_id(device_id)
|
||||
if account:
|
||||
subscription = account.subscription
|
||||
response = {'@type': subscription.type if subscription is not None else 'free'}, HTTPStatus.OK
|
||||
membership = account.membership
|
||||
response = {'@type': membership.type if membership is not None else 'free'}, HTTPStatus.OK
|
||||
else:
|
||||
response = '', HTTPStatus.NO_CONTENT
|
||||
return response
|
||||
|
|
|
@ -24,7 +24,7 @@ account = Account(
|
|||
AccountAgreement(type=PRIVACY_POLICY, accept_date=date.today()),
|
||||
AccountAgreement(type=TERMS_OF_USE, accept_date=date.today())
|
||||
],
|
||||
subscription=None
|
||||
membership=None
|
||||
)
|
||||
|
||||
wake_word = WakeWord(
|
||||
|
|
|
@ -6,7 +6,7 @@ from http import HTTPStatus
|
|||
from behave import when, then
|
||||
from hamcrest import assert_that, has_entry, equal_to
|
||||
|
||||
from selene.data.account import AccountRepository, AccountSubscription
|
||||
from selene.data.account import AccountRepository, AccountMembership
|
||||
from selene.util.db import get_db_connection
|
||||
|
||||
|
||||
|
@ -25,9 +25,9 @@ def validate_response(context):
|
|||
|
||||
@when('the subscription endpoint is called for a monthly account')
|
||||
def get_device_subscription(context):
|
||||
membership = AccountSubscription(start_date=date.today(), type='Monthly Supporter', stripe_customer_id='test_monthly')
|
||||
membership = AccountMembership(start_date=date.today(), type='Monthly Supporter', stripe_customer_id='test_monthly')
|
||||
with get_db_connection(context.client_config['DB_CONNECTION_POOL']) as db:
|
||||
AccountRepository(db).add_membership(context.account.id, membership)
|
||||
AccountRepository(db)._add_membership(context.account.id, membership)
|
||||
context.subscription_response = context.client.get('/device/{uuid}/subscription'.format(uuid=context.device_id))
|
||||
|
||||
|
||||
|
|
|
@ -146,7 +146,8 @@ for schema in SCHEMAS:
|
|||
template_db.close_db()
|
||||
|
||||
print('Copying template to new database.')
|
||||
postgres_db = PostgresDB(dbname='postgres', user='chrisveilleux')
|
||||
# Copy template to new database.
|
||||
postgres_db = PostgresDB(dbname='postgres', user='postgres')
|
||||
postgres_db.execute_sql(get_sql_from_file('create_mycroft_db.sql'))
|
||||
postgres_db.close_db()
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ end = time.time()
|
|||
|
||||
print('Time to load CSVs {}'.format(end - start))
|
||||
print('Importing the skills table')
|
||||
"""
|
||||
|
||||
start = time.time()
|
||||
print('Importing account table')
|
||||
fill_account_table()
|
||||
|
@ -463,6 +463,5 @@ fill_device_category_table()
|
|||
print('Importing device table')
|
||||
fill_device_table()
|
||||
fill_skills_table()
|
||||
"""
|
||||
end = time.time()
|
||||
print('Time to import: {}'.format(end-start))
|
||||
|
|
|
@ -31,32 +31,32 @@ WITH
|
|||
WHERE
|
||||
dev.id = %(device_id)s
|
||||
),
|
||||
subscription AS (
|
||||
membership AS (
|
||||
SELECT
|
||||
json_build_object(
|
||||
'id', asub.id,
|
||||
'type', s.subscription,
|
||||
'start_date', lower(asub.subscription_ts_range)::DATE,
|
||||
'stripe_customer_id', asub.stripe_customer_id
|
||||
'id', acc_mem.id,
|
||||
'type', mem.type,
|
||||
'start_date', lower(acc_mem.membership_ts_range)::DATE,
|
||||
'stripe_customer_id', acc_mem.stripe_customer_id
|
||||
)
|
||||
FROM
|
||||
account.account_subscription asub
|
||||
account.account_membership acc_mem
|
||||
INNER JOIN
|
||||
account.subscription s ON asub.subscription_id = s.id
|
||||
account.membership mem ON acc_mem.membership_id = mem.id
|
||||
INNER JOIN
|
||||
account.account acc ON asub.account_id = acc.id
|
||||
account.account acc ON acc_mem.account_id = acc.id
|
||||
INNER JOIN
|
||||
device.device dev ON acc.id = dev.account_id
|
||||
WHERE
|
||||
dev.id = %(device_id)s
|
||||
AND upper(asub.subscription_ts_range) IS NULL
|
||||
AND upper(acc_mem.membership_ts_range) IS NULL
|
||||
)
|
||||
SELECT
|
||||
json_build_object(
|
||||
'id', acc.id,
|
||||
'email_address', acc.email_address,
|
||||
'username', acc.username,
|
||||
'subscription', (SELECT * FROM subscription),
|
||||
'membership', (SELECT * FROM membership),
|
||||
'refresh_tokens', (SELECT * FROM refresh_tokens),
|
||||
'agreements', (SELECT * FROM agreements)
|
||||
) as account
|
||||
|
|
Loading…
Reference in New Issue