Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added architecture tests + fix bugs + added missing functions #32

Merged
merged 3 commits into from
Oct 25, 2019

Conversation

NicolasBonduel
Copy link
Member

No description provided.

products = builton.product().search(query=query, json=True)
assert isinstance(products, list)

for product in products:
print(product['name'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, remove the print

class User(Component):
def __init__(self, request, props):
super(User, self).__init__(request, props)
self.api_path = 'users'

def authenticate(cls, *args, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

def get_providers(self, url_params=None, json=False):
return self.simple_query(resource='providers', url_params=url_params, json=json,
res_constructor=Provider)
def get_resources(self, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

json=json)
body=body, json=json)

def get_payments(self, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

return self.simple_query(_type='put', resource='bulk', body=body, url_params=url_params,
json=json)

def get_orders(self, body, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

@@ -11,3 +12,11 @@ def __init__(self, request, props):
def create_bulk(self, body, url_params=None, json=False):
return self.simple_query(_type='post', resource='bulk', body=body, url_params=url_params,
json=json)

def update_bulk(self, body, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

return self.simple_query(_id=self.id, resource='sub_products', url_params=url_params,
json=json)

def search_subproducts(self, query="", url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

@@ -7,3 +7,11 @@ class Product(Component):
def __init__(self, request, props):
super(Product, self).__init__(request, props)
self.api_path = 'products'

def get_subproducts(self, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?



@rest_decorator(create, delete, get, get_all, refresh, update, search)
class Plan(Component):
def __init__(self, request, props):
super(Plan, self).__init__(request, props)
self.api_path = 'plans'

def get_subscriptions(self, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

url_params=url_params,
json=json)

def confirm(self, body, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

@@ -7,3 +7,13 @@ class Payment(Component):
def __init__(self, request, props):
super(Payment, self).__init__(request, props)
self.api_path = 'payments'

def pay(self, body, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

url_params=url_params,
res_constructor=None
)
def get_payments(self, url_params=None, json=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

@@ -17,6 +17,10 @@ def get_recommendations(self, body, url_params=None):
return self.simple_query(_type='post', _id=_id, resource='invoke', url_params=url_params,
body=body, json=True)

def create_version(self, body, url_params=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a test for it?

actual_functions = get_functions_of(obj)
expected_functions = get_expected_functions_of(obj)
print(actual_functions)
print(expected_functions)
Copy link
Contributor

@cathoderay cathoderay Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please remove the prints?

if fn not in ignore_functions:
functions.append(fn)
functions.sort()
return functions
Copy link
Contributor

@cathoderay cathoderay Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion/alternative way:

return sorted([f for f in dir(obj) if f not in ignore_functions])

def get_expected_functions_of(obj):
function_name = obj.__name__
with open('./tests/architecture/architecture.json', 'r') as f:
test = json.load(f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:
test = json.load(f)[function_name] would make the following list a bit shorter

@@ -0,0 +1,344 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the iniciative of having this file! =)

Copy link
Contributor

@cathoderay cathoderay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @NicolasBonduel! Sorry for taking too long to approve it!

@cathoderay cathoderay merged commit 421e483 into master Oct 25, 2019
@cathoderay cathoderay added the medium medium impact label Oct 25, 2019
@cathoderay cathoderay deleted the architecture-test branch October 25, 2019 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium medium impact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants