def test_entity_to(self): user_profile = self.fixture() entity = UserProfileEntityTransformer.as_entity(user_profile) up = UserProfileEntityTransformer.from_entity(entity) assert_that(up.email, equal_to('*****@*****.**')) assert_that(up.given_name, equal_to('unittest')) assert_that(up.family_name, equal_to('test')) assert_that(up.avatar_url, equal_to('http://gravatar.nl/go.jpg'))
def test_instance_of_new_class(self): value1 = 'value1' value2 = 'value2' model = TestModel(field1=value1, field2=value2) assert_that(model.field1, equal_to(value1)) assert_that(model.field2, equal_to(value2))
def test_transform_to_entity(self): user_profile = self.fixture() entity = UserProfileEntityTransformer.as_entity(user_profile) assert_that(entity['email'], equal_to('*****@*****.**')) assert_that(entity['given_name'], equal_to('unittest')) assert_that(entity['family_name'], equal_to('test')) assert_that(entity['avatar_url'], equal_to('http://gravatar.nl/go.jpg'))
def test_client_receives_200_when_movies_not_found(setup_test_tc_002, client_api, device): """Verify that client receives ok status and empty list of movies, if movies are not found """ client = client_api(device) r = client.get_movies() assert_that(r.status_code, equal_to(200)) assert_that(r.json()['items'], equal_to([]))
def test_from_data_source(self): properties = Mock() properties.db_field1 = 'value1' properties.db_field2 = 'value2' properties.db_relation1 = 'relation1' model = TestModel.from_data_source(properties) assert_that(model.field1, equal_to('value1')) assert_that(model.field2, equal_to('value2')) assert_that(model.relation1, equal_to('relation1'))
def test_to_data_source(self): Source = Mock() source_obj = Source.return_value = Mock() model = TestModel(field1='value1', field2='value2') data_source = model.to_data_source(Source) assert_that(source_obj, same_instance(data_source)) assert_that(data_source.db_field1, equal_to('value1')) assert_that(data_source.db_field2, equal_to('value2'))
def test_from_user_data(self): properties = { 'field1': 'value1', 'field2': 'value2', 'relation1': 'relation1', } model = TestModel.from_user_data(properties) assert_that(model.field1, equal_to('value1')) assert_that(model.field2, equal_to('value2')) assert_that(model.relation1, equal_to('relation1'))
def step(context, page_name): if (page_name == 'Owning a Home'): context.base.go(HOME) elif (page_name == 'Loan Comparison'): context.base.go(LC) elif (page_name == 'Loan Options'): context.base.go(LO) elif (page_name == 'Rate Checker'): context.base.go(RC) # Wait for the chart to load context.base.sleep(2) assert_that(context.rate_checker.is_chart_loaded(), equal_to("Chart is loaded")) elif (page_name == 'Conventional Loan'): context.base.go(CONV) elif (page_name == 'FHA Loan'): context.base.go(FHA) elif (page_name == 'Special Loan Programs'): context.base.go(SPECIAL) elif (page_name == 'Know the Process'): context.base.go(KP) elif (page_name == 'Prepare to Shop'): context.base.go(PP) elif (page_name == 'Explore Loan Options'): context.base.go(PE) elif (page_name == 'Compare Loan Options'): context.base.go(PC) elif (page_name == 'Get Ready to Close'): context.base.go(PF) else: raise Exception(page_name + ' is NOT a valid page')
def step(context, page_name): if page_name == "Owning a Home": context.base.go(HOME) elif page_name == "Loan Comparison": context.base.go(LC) elif page_name == "Loan Options": context.base.go(LO) elif page_name == "Rate Checker": context.base.go(RC) # Wait for the chart to load context.base.sleep(2) assert_that(context.rate_checker.is_chart_loaded(), equal_to("Chart is loaded")) elif page_name == "Conventional Loan": context.base.go(CONV) elif page_name == "FHA Loan": context.base.go(FHA) elif page_name == "Special Loan Programs": context.base.go(SPECIAL) elif page_name == "Know the Process": context.base.go(KP) elif page_name == "Prepare to Shop": context.base.go(PP) elif page_name == "Explore Loan Options": context.base.go(PE) elif page_name == "Compare Loan Options": context.base.go(PC) elif page_name == "Get Ready to Close": context.base.go(PF) elif page_name == "Closing Disclosure": context.base.go(CD) elif page_name == "Loan Estimate": context.base.go(LE) else: raise Exception(page_name + " is NOT a valid page")
def test_client_receives_403_when_invalid_token(client_api, token): """Verify that client cant get movies without token """ client = client_api('tv') client.token = str(token) r = client.get_movies() assert_that(r.status_code, equal_to(403)) assert_that(r.json()['message'], contains_string("'Токен не найден'"))
def step(context, param_name): expected_reponse = "Required parameter '" + param_name + "' is missing" context.json_data = json.loads(context.response.text) context.logger.debug("JSON detail is: %s" % context.json_data['detail']) context.logger.debug("JSON text is: %s" % context.response.text) assert_that(context.json_data['detail'], equal_to(expected_reponse))
def resizing_window_changes_image_size(context, css_selector): original_size = context.closing_disclosure._element_size(css_selector) context.closing_disclosure.resize_to_mobile_size() new_size = context.closing_disclosure._element_size(css_selector) assert_that( original_size, not equal_to(new_size), 'Sizes are not the same original: %s, new: %s' % (original_size, new_size))
def test_update_from_data(self): model = TestModel(field1='value1') data_update = {'field1': 'updated_value'} model.update_from_data(data_update) assert_that(model.field1, equal_to('updated_value'))
def resizing_window_changes_image_size(context, css_selector): original_size = context.closing_disclosure._element_size(css_selector) context.closing_disclosure.resize_to_mobile_size() new_size = context.closing_disclosure._element_size(css_selector) assert_that( original_size, not equal_to(new_size), "Sizes are not the same original: %s, new: %s" % (original_size, new_size), )
def test_set_userfield_empty(self): user = a_user().build() outcall = an_outcall().build() self.outgoing_features.outcall = outcall self.outgoing_features.user = user self.outgoing_features._set_userfield() assert_that(self._agi.set_variable.call_count, equal_to(0), 'Set variable call count')
def test_update_from_data(self): model = TestModel(field1='value1') data_update = { 'field1': 'updated_value' } model.update_from_data(data_update) assert_that(model.field1, equal_to('updated_value'))
def test_set_user_music_on_hold_empty(self): user = a_user().build() outcall = an_outcall().build() self.outgoing_features.outcall = outcall self.outgoing_features.user = user self.outgoing_features._set_user_music_on_hold() assert_that(self._agi.set_variable.call_count, equal_to(0), 'Set variable call count')
def test_client_receives_movies_only_for_platform(setup_test_tc_003, get_movies): """ """ device, service_id, movie_id = setup_test_tc_003 items = get_movies(device) movie = next((item for item in items if item.get('id', 0) == movie_id), None) assert_that(movie, not_none(), f'Movie with id {movie_id} not found') assert_that(movie['services'][0]['id'], equal_to(service_id), f'Not found movie for platform {device}')
def _get_movies(device): my_logger.debug(f"Start {request.node.name}") client = TestClient(my_logger, prefix_url=test_config.basic_url, device_type=device) r = client.get_movies() assert_that(r.status_code, equal_to(200)) items = r.json()['items'] assert_that(len(items), greater_than(0), f'There are no movies for {device}') my_logger.debug('\n'.join(str(x) for x in items)) return items
def step(context, page_name): if (page_name == 'Owning a Home'): context.base.go(HOME) elif (page_name == 'Loan Comparison'): context.base.go(LC) elif (page_name == 'Loan Options'): context.base.go(LO) elif (page_name == 'Rate Checker'): context.base.go(RC) # Wait for the chart to load context.base.sleep(1) assert_that(context.rate_checker.is_chart_loaded(), equal_to(True)) elif (page_name == 'Conventional Loan'): context.base.go(CONV) elif (page_name == 'FHA Loan'): context.base.go(FHA) elif (page_name == 'Special Loan Programs'): context.base.go(SPECIAL) else: raise Exception(page_name + ' is NOT a valid page')
def step(context, loan_term): actual_term = context.loan_options.get_loan_term() assert_that(actual_term, equal_to(loan_term))
def step(context, section_name): context.base.sleep(2) actual_text = context.loan_options.get_subsection_text(section_name) assert_that(actual_text, equal_to('Section NOT visible'))
def step(context, interest_rate): actual_value = context.loan_options.get_interest_rate() assert_that(actual_value, equal_to(interest_rate))
def navbar_is_loaded(context): assert_that(context.journey.is_navbar_found(), equal_to(True), "Navbar found")
def step(context, section_name): caption = context.loan_options.get_expand_button_caption(section_name) assert_that(caption, equal_to('Collapse'))
def links_working_without_404s(context): assert_that( context.navigation.check_links_for_404s(context.base_url), equal_to([]), 'Broken links on <%s>' % context.base.get_current_url() )
def navbar_is_loaded(context): assert_that(context.journey.is_navbar_found(), equal_to(True), 'Navbar found')
def step_impl(context, expected_amount, loan_column): displayed_amount = context.loan_comparison.get_loan_amount(loan_column) assert_that(displayed_amount, equal_to(expected_amount))
def test_equal_same(self): model1 = StubModel(field1='a', field2='b') model2 = StubModel(field1='a', field2='b') assert_that(model1, equal_to(model2))
def step(context, state_name): selected_state = context.loan_comparison.get_location() assert_that(selected_state, equal_to(state_name))
def step(context, expected_score): selected_score = context.loan_comparison.get_credit_score() assert_that(selected_score, equal_to(expected_score))
def step(context, loan_column): is_present = context.loan_comparison.is_column_present(loan_column) assert_that(is_present, equal_to(False))
def step(context, expected_points, loan_column): actual_points = context.loan_comparison.get_selected_points(loan_column) assert_that(actual_points, equal_to(expected_points))
def step(context, loan_amount): actual_value = context.loan_options.get_loan_amount() assert_that(actual_value, equal_to(loan_amount))
def step(context): actual_url = context.base.get_current_url() expected_url = context.utils.build_url(context.base_url, '/') assert_that(actual_url, equal_to(expected_url))
def step(context, relative_url): actual_url = context.base.get_current_url() expected_url = context.utils.build_url(context.base_url, relative_url) assert_that(actual_url, equal_to(expected_url))
def step(context, expected_price, loan_column): displayed_amount = context.loan_comparison.get_house_price(loan_column) assert_that(displayed_amount, equal_to(expected_price))
def step(context, expected_value, loan_column): actual_value = context.loan_comparison.get_down_payment_amount(loan_column) assert_that(actual_value, equal_to(expected_value))
def step(context, expected_value, loan_column): actual_value = context.loan_comparison.get_arm_type(loan_column) assert_that(actual_value, equal_to(expected_value))
def test_client_all_movies_as_expected(setup_test_tc_009, get_movies): device, ids_movie = setup_test_tc_009 items = get_movies(device) movies = [item.get('id', 0) for item in items] assert_that(movies, equal_to(ids_movie))
def all_links_working(context): assert_that( context.journey.check_all_links_on_page(context.base_url + '/process'), equal_to([]), 'Broken links on <%s>' % context.base.get_current_url())
def test_movie_data_in_response(setup_test_tc_010, get_movies): device, movie_id, movie_dict = setup_test_tc_010 items = get_movies(device) movie = next((item for item in items if item['id'] == movie_id), None) assert_that(movie, equal_to(movie_dict))
def all_links_working(context): assert_that( context.journey.check_all_links_on_page(context.base_url + "/process"), equal_to([]), "Broken links on <%s>" % context.base.get_current_url(), )
def step(context, section_name): actual_text = context.loan_options.get_subsection_text(section_name) assert_that(actual_text, equal_to('Section NOT visible'))
def step(context, expected_text, section_name): actual_text = context.loan_options.get_subsection_text(section_name) assert_that(actual_text, equal_to(expected_text))
def test_equal_same(self): name = 'samename' line_1 = Line(name=name) line_2 = Line(name=name) assert_that(line_1, equal_to(line_2))