def test_search_business_by_exact_name_query(self): """ Test searchBusiness Query to get business record for specific name """ query = ''' query { searchBusiness(name_Iexact: "zomato"){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'Zomato' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Gaurav Gupta' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'Gurgaon, Haryana, India' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 5001
def test_create_business_mutation(self): """ Testing Mutation for creation of Business normally """ mutation = ''' mutation CreateBusinessMutation{ createBusiness(name: "Eichiba Inc", owner: "Anweshan Guha", address: "San Jose, California, United States", employeeCount:10){ business{ name, owner, address, employeeCount } message, status } } ''' result = schema.execute(mutation) assert result is not None result_dict = result.to_dict() assert result_dict['data']['createBusiness']['status'] == 200 assert result_dict['data']['createBusiness'][ 'message'] == 'Business Info successfully added' assert result_dict['data']['createBusiness']['business'][ 'name'] == 'Eichiba Inc' assert result_dict['data']['createBusiness']['business'][ 'owner'] == 'Anweshan Guha' assert result_dict['data']['createBusiness']['business'][ 'address'] == 'San Jose, California, United States' assert result_dict['data']['createBusiness']['business'][ 'employeeCount'] == 10
def test_search_business_by_name_contains_query(self): """ Test searchBusiness Query to get business record for name containing specific keyword """ query = ''' query { searchBusiness(name_Icontains: "bank"){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'SoftBank' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Masayoshi Son' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'Tokyo, Japan' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 10001
def test_search_business_by_greaterthan_employeeCount_query(self): """ Test searchBusiness Query to get employeeCount greater than specific number """ query = ''' query { searchBusiness(employeeCount_Gt: 4500){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'SoftBank' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Masayoshi Son' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'Tokyo, Japan' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 10001 assert result_dict['data']['searchBusiness']['edges'][1]['node'][ 'name'] == 'Zomato' assert result_dict['data']['searchBusiness']['edges'][1]['node'][ 'owner'] == 'Gaurav Gupta' assert result_dict['data']['searchBusiness']['edges'][1]['node'][ 'address'] == 'Gurgaon, Haryana, India' assert result_dict['data']['searchBusiness']['edges'][1]['node'][ 'employeeCount'] == 5001
def test_search_business_by_lessthan_employeeCount_query(self): """ Test searchBusiness Query to get employeeCount less than specific number """ query = ''' query { searchBusiness(employeeCount_Lt: 500){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'Fireblocks' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Idan Ofrat' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'New York, New York, United States' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 250
def test_search_business_by_owner_startswith_query(self): """ Test searchBusiness Query to get business record for owner starting with certain keyword """ query = ''' query { searchBusiness(owner_Istartswith: "Masa"){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'SoftBank' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Masayoshi Son' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'Tokyo, Japan' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 10001
def test_search_business_by_owner_contains_query(self): """ Test searchBusiness Query to get business record for owner containing specific keyword """ query = ''' query { searchBusiness(owner_Icontains: "Gaurav"){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'Zomato' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Gaurav Gupta' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'Gurgaon, Haryana, India' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 5001
def test_search_business_by_exact_owner_query(self): """ Test searchBusiness Query to get business record for specific owner """ query = ''' query { searchBusiness(owner_Iexact: "Idan Ofrat"){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'Fireblocks' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Idan Ofrat' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'New York, New York, United States' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 250
def test_search_business_by_name_startswith_query(self): """ Test searchBusiness Query to get business record for name starting with certain keyword """ query = ''' query { searchBusiness(name_Icontains: "fire"){ edges{ node{ name, owner, address, employeeCount } } } } ''' result = schema.execute(query) assert result is not None result_dict = result.to_dict() assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'name'] == 'Fireblocks' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'owner'] == 'Idan Ofrat' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'address'] == 'New York, New York, United States' assert result_dict['data']['searchBusiness']['edges'][0]['node'][ 'employeeCount'] == 250
def test_all_business_query(self): """ Test allBusiness Query to get all the records""" query = ''' query{ allBusiness{ name, owner, address, employeeCount } } ''' result = schema.execute(query) assert result is not None assert result.to_dict() == self.data_dict
def test_delete_business_does_not_exist_mutation(self): """ Testing Mutation for deletion of Business that does not exist in records """ mutation = ''' mutation DeleteBusinessMutation{ deleteBusiness(name: "CoinSwitch Kuber"){ message, status } } ''' result = schema.execute(mutation) assert result is not None result_dict = result.to_dict() assert result_dict['data']['deleteBusiness']['status'] == 400 assert result_dict['data']['deleteBusiness'][ 'message'] == 'Business with name CoinSwitch Kuber does not exist'
def test_delete_business_mutation(self): """ Testing Mutation for deletion of Business normally """ mutation = ''' mutation DeleteBusinessMutation{ deleteBusiness(name: "Zomato"){ message, status } } ''' result = schema.execute(mutation) assert result is not None result_dict = result.to_dict() assert result_dict['data']['deleteBusiness']['status'] == 200 assert result_dict['data']['deleteBusiness'][ 'message'] == 'Business Info successfully deleted'
def test_create_business_already_exists_mutation(self): """ Testing Mutation for creation of Business that already exists in records""" mutation = ''' mutation CreateBusinessMutation{ createBusiness(name: "Zomato", owner: "Gaurav Gupta", address: "Gurgaon, Haryana, India", employeeCount:5001){ business{ name, owner, address, employeeCount } message, status } } ''' result = schema.execute(mutation) assert result is not None result_dict = result.to_dict() assert result_dict['data']['createBusiness']['status'] == 400 assert result_dict['data']['createBusiness'][ 'message'] == 'Business with name Zomato already exists' assert result_dict['data']['createBusiness']['business'] is None
def test_update_business_does_not_exist_mutation(self): """ Testing Mutation for updation of Business that does not exist in records """ mutation = ''' mutation UpdateBusinessMutation{ updateBusiness(name: "CoinSwitch Kuber", owner: "Ashish Singhal", address: "Bangalore, Karnataka, India", employeeCount:2000){ business{ name, owner, address, employeeCount } message, status } } ''' result = schema.execute(mutation) assert result is not None result_dict = result.to_dict() assert result_dict['data']['updateBusiness']['status'] == 400 assert result_dict['data']['updateBusiness'][ 'message'] == 'Business with name CoinSwitch Kuber does not exist' assert result_dict['data']['updateBusiness']['business'] is None
def test_update_business_mutation(self): """ Testing Mutation for updation of Business normally """ mutation = ''' mutation UpdateBusinessMutation{ updateBusiness(name: "Zomato", owner: "Deepinder Goyal", address: "Gurgaon, Haryana, India", employeeCount:5001){ business{ name, owner, address, employeeCount } message, status } } ''' result = schema.execute(mutation) assert result is not None result_dict = result.to_dict() assert result_dict['data']['updateBusiness']['status'] == 200 assert result_dict['data']['updateBusiness'][ 'message'] == 'Business Info successfully updated' assert result_dict['data']['updateBusiness']['business'][ 'owner'] == 'Deepinder Goyal'