Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
fix api issues to run tests on stage/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vaidik committed Aug 21, 2013
1 parent 79ef04d commit 323348b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
5 changes: 4 additions & 1 deletion credentials.yaml
Expand Up @@ -36,7 +36,10 @@ default:
email: <value>
password: <value>
name: <value>
api:
api-dev:
key: <value>
secret: <value>
api-stage:
key: <value>
secret: <value>
paypal:
Expand Down
17 changes: 17 additions & 0 deletions mocks/marketplace_api.py
Expand Up @@ -175,3 +175,20 @@ def get_app(self, app):
response = self._client.conn.fetch('GET', self._client.url('app') % app)
response = json.loads(response.text)
return response

@staticmethod
def get_client(base_url, credentials):
api_keys = MarketplaceAPI.get_credentials(base_url, credentials)
client = MarketplaceAPI(credentials=api_keys)

if 'dev' not in base_url:
client = MarketplaceAPI(credentials=api_keys, domain='marketplace.allizom.org')

return client

@staticmethod
def get_credentials(base_url, credentials):
if 'dev' in base_url:
return credentials['api-dev']
else:
return credentials['api-stage']
2 changes: 1 addition & 1 deletion mocks/mock_application.py
Expand Up @@ -16,7 +16,7 @@ def __init__(self, **kwargs):
self['name'] = 'Mock Application %s' % current_time
self['url_end'] = 'marble-run-%s' % current_time
self['summary'] = 'Summary of marble app %s' % current_time
self['categories'] = [('Entertainment', True),
self['categories'] = [('Music', True),
('Games', True)]
self['description'] = 'more details of marble app %s' % current_time
self['privacy_policy'] = 'privacy policy of testapp %s' % current_time
Expand Down
4 changes: 3 additions & 1 deletion tests/desktop/consumer_pages/test_reviews.py
Expand Up @@ -18,7 +18,9 @@
class TestReviews:

def _reviews_setup(self, mozwebqa):
self.mk_api = MarketplaceAPI(credentials=mozwebqa.credentials['api']) # init API client
# init API client
self.mk_api = MarketplaceAPI.get_client(mozwebqa.base_url,
mozwebqa.credentials)

# Submit a review using marketplace API
mock_review = MockReview()
Expand Down
5 changes: 3 additions & 2 deletions tests/desktop/developer_hub/test_api_submit.py
Expand Up @@ -19,8 +19,9 @@ def test_assert_that_a_app_can_be_added_by_api(self, mozwebqa):
mock_app = MockApplication() # generate mock app
mock_app.name = 'API %s' % mock_app.name

# API
mk_api = MarketplaceAPI(credentials=mozwebqa.credentials['api']) # init API client
# init API client
mk_api = MarketplaceAPI.get_client(mozwebqa.base_url,
mozwebqa.credentials)

mk_api.submit_app(mock_app) # submit app

Expand Down
2 changes: 1 addition & 1 deletion tests/mobile/test_reviews.py
Expand Up @@ -18,7 +18,7 @@
class TestReviews():

def _reviews_setup(self, mozwebqa):
self.mk_api = MarketplaceAPI(credentials=mozwebqa.credentials['api'])
self.mk_api = MarketplaceAPI.get_client(mozwebqa.base_url, mozwebqa.credentials)

def test_that_after_writing_a_review_clicking_back_goes_to_app_page(self, mozwebqa):
"""Logged out, click "Write a Review" on an app page, sign in, submit a review,
Expand Down

0 comments on commit 323348b

Please sign in to comment.