def test_send_transaction_from_daap(self): home = HomeView(self.driver) recover_access(home, transaction_users['B_USER']['passphrase'], transaction_users['B_USER']['password'], transaction_users['B_USER']['username']) chats = home.get_chats() address = transaction_users['B_USER']['address'] initial_balance = chats.get_balance(address) contacts = chats.contacts_button.click() auction_house = contacts.auction_house_button.click() auction_house.toggle_navigation_button.click() auction_house.new_auction_button.click() auction_house.name_to_reserve_input.click() auction_name = time.strftime('%Y-%m-%d-%H-%M') auction_house.send_as_keyevent(auction_name) auction_house.register_name_button.click() chats.sign_transaction_button.wait_for_element(20) chats.sign_transaction_button.click() chats.enter_password_input.send_keys(transaction_users['B_USER']['password']) chats.sign_transaction_button.click() chats.got_it_button.click() auction_house.find_full_text('You are the proud owner of the name: ' + auction_name, 120) chats.verify_balance_is_updated(initial_balance, address)
def test_send_transaction_from_wallet(self, test, recipient, sender): home = HomeView(self.driver) recover_access(home, transaction_users[sender]['passphrase'], transaction_users[sender]['password'], transaction_users[sender]['username']) chats = home.get_chats() chats.wait_for_syncing_complete() recipient_key = transaction_users[recipient]['public_key'] recipient_address = transaction_users[recipient]['address'] initial_balance_recipient = chats.get_balance(recipient_address) chats.plus_button.click() chats.add_new_contact.click() chats.public_key_edit_box.send_keys(recipient_key) chats.confirm() chats.confirm_public_key_button.click() for _ in range(2): chats.back_button.click() wallet = chats.wallet_button.click() wallet.send_button.click() wallet.amount_edit_box.click() amount = '0,0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S') wallet.send_as_keyevent(amount) wallet.confirm() wallet.chose_recipient_button.click() wallet.deny_button.click() wallet.chose_from_contacts_button.click() user_contact = chats.element_by_text( transaction_users[recipient]['username'], 'button') user_contact.click() if test == 'sign_later': chats.sign_later_button.click() wallet.yes_button.click() wallet.ok_button_apk.click() tr_view = wallet.transactions_button.click() tr_view.unsigned_tab.click() tr_view.sign_button.click() chats.sign_transaction_button.click() chats.enter_password_input.send_keys( transaction_users[sender]['password']) chats.sign_transaction_button.click() chats.got_it_button.click() chats.verify_balance_is_updated(initial_balance_recipient, recipient_address) if test == 'sign_later': tr_view.history_tab.click() else: chats.wallet_button.click() tr_view = wallet.transactions_button.click() transaction = tr_view.transactions_table.find_transaction( amount=amount.replace(',', '.')) details_view = transaction.click() transaction_hash = details_view.get_transaction_hash() verify_transaction_in_ropsten( address=transaction_users[sender]['address'], transaction_hash=transaction_hash)
def test_change_profile_name_and_status(self): home = HomeView(self.driver) set_password_as_new_user(home) chats = home.get_chats() chats.back_button.click() chats.profile_button.click() profile = chats.profile_icon.click() new_status = '#newstatus' new_username = '******' profile.user_status_box.click() profile.user_status_input.clear() profile.user_status_input.send_keys(new_status) profile.username_input.clear() profile.username_input.send_keys(new_username) profile.save_button.click() profile.back_button.click() chats.profile_button.click() login = chats.switch_users_button.click() user = login.element_by_text(new_username, 'button') user.click() login.password_input.send_keys('qwerty1234') login.sign_in_button.click() home.find_full_text('Chats', 60) chats.profile_button.click() for text in new_status + ' ', new_username: chats.find_full_text(text, 5)
def test_send_transaction(self, test, recipient, sender): home = HomeView(self.driver) recover_access(home, transaction_users[sender]['passphrase'], transaction_users[sender]['password'], transaction_users[sender]['username']) chats = home.get_chats() chats.wait_for_syncing_complete() sender_address = transaction_users[sender]['address'] recipient_address = transaction_users[recipient]['address'] recipient_key = transaction_users[recipient]['public_key'] initial_balance_recipient = chats.get_balance(recipient_address) chats.plus_button.click() chats.add_new_contact.click() chats.public_key_edit_box.send_keys(recipient_key) chats.confirm() chats.confirm_public_key_button.click() if test == 'group_chat': user_name = chats.user_name_text.text chats.back_button.click() chats.new_group_chat_button.click() user_contact = chats.element_by_text(user_name, 'button') user_contact.scroll_to_element() user_contact.click() chats.next_button.click() chats.name_edit_box.send_keys('chat_send_transaction') chats.save_button.click() chats.send_funds_button.click() if test == 'group_chat': chats.first_recipient_button.click() chats.send_as_keyevent('0,1') else: chats.send_as_keyevent('0,1') chats.send_message_button.click() chats.sign_transaction_button.wait_for_element(20) chats.sign_transaction_button.click() if test == 'wrong_password': chats.enter_password_input.send_keys('invalid') chats.sign_transaction_button.click() chats.find_full_text('Wrong password', 20) else: chats.enter_password_input.send_keys(transaction_users[sender]['password']) chats.sign_transaction_button.click() chats.got_it_button.click() chats.find_full_text('0.1') try: chats.find_full_text('Sent', 10) except NoSuchElementException: chats.find_full_text('Delivered', 10) if test == 'group_chat': chats.find_full_text('to ' + transaction_users[recipient]['username'], 60) chats.verify_balance_is_updated(initial_balance_recipient, recipient_address)
def test_wallet_error_messages(self): home = HomeView(self.driver) set_password_as_new_user(home) chats = home.get_chats() chats.back_button.click() wallet_view = chats.wallet_button.click() wallet_view.send_button.click() wallet_view.amount_edit_box.send_keys('asd') wallet_view.find_full_text('Amount is not a valid number') wallet_view.amount_edit_box.send_keys('0,1') wallet_view.find_full_text('Insufficient funds')
def test_recover_access(self): home = HomeView(self.driver) set_password_as_new_user(home) chats = home.get_chats() chats.back_button.click() chats.profile_button.click() login = chats.switch_users_button.click() login.recover_access_button.click() login.passphrase_input.send_keys(basic_user['passphrase']) login.password_input.send_keys(basic_user['password']) login.confirm_recover_access.click() recovered_user = login.element_by_text(basic_user['username'], 'button') recovered_user.click() login.password_input.send_keys(basic_user['password']) login.sign_in_button.click() home.find_full_text('Chats', 60)
def test_new_profile_name_and_status_on_discover(self): device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) set_password_as_new_user(device_1, device_2) device_1.back_button.click() device_2.back_button.click() chats_d1, chats_d2 = device_1.get_chats(), device_2.get_chats() chats_d2.profile_button.click() profile_d2 = chats_d2.profile_icon.click() d2_public_key = profile_d2.public_key_text.text chats_d1.plus_button.click() chats_d1.add_new_contact.click() chats_d1.public_key_edit_box.send_keys(d2_public_key) chats_d1.confirm() chats_d1.confirm_public_key_button.click() chats_d1.chat_message_input.send_keys('test123') chats_d1.send_message_button.click() chats_d2.back_button.click() new_chat_d2 = chats_d2.element_by_text('test123', 'button') new_chat_d2.click() chats_d1.back_button.click() chats_d1.back_button.click() chats_d2.add_to_contacts.click() chats_d2.back_button.click() chats_d1.profile_button.click() chats_d2.profile_button.click() profile_d1, profile_d2 = chats_d1.profile_icon.click( ), chats_d2.profile_icon.click() users_details = change_user_details(profile_d1, profile_d2) profile_d1.back_button.click() profile_d2.back_button.click() discover_d1 = profile_d1.discover_button.click() discover_d2 = profile_d2.discover_button.click() for device in discover_d1, discover_d2: device.all_popular.click() for k in users_details: device.find_full_text(users_details[k]['name']) device.find_full_text(' ' + users_details[k]['status']) device.back_button.click() device.all_recent.click() for k in users_details: device.find_full_text(users_details[k]['name']) device.find_full_text(users_details[k]['status'] + ' ')
def test_balance_and_eth_rate(self): errors = list() home = HomeView(self.driver) recover_access(home, passphrase=transaction_users['A_USER']['passphrase'], password=transaction_users['A_USER']['password'], username=transaction_users['A_USER']['username']) chats = home.get_chats() address = transaction_users['A_USER']['address'] balance = chats.get_balance(address) / 1000000000000000000 eth_rate = get_ethereum_price_in_usd() wallet = chats.wallet_button.click() wallet_balance = wallet.get_eth_value() if wallet_balance != balance: errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance)) wallet.verify_eth_rate(eth_rate, errors) assert not errors, 'errors occurred:\n{}'.format('\n'.join(errors))
def test_sign_in(self, verification): verifications = {"valid": {"input": "qwerty1234", "outcome": "Chats"}, "invalid": {"input": "12345ewq", "outcome": "Wrong password"}} home = HomeView(self.driver) set_password_as_new_user(home) chats = home.get_chats() chats.back_button.click() chats.profile_button.click() login = chats.switch_users_button.click() login.first_account_button.click() login.password_input.send_keys(verifications[verification]['input']) login.sign_in_button.click() home.find_full_text(verifications[verification]["outcome"], 60)
def render(self, breadcrumbs, store): result = None valid_answers = { '1': 'controllers.loginuserncontroller', '2': 'controllers.registercontroller', 'S': None, } header = MainHeader() body = HomeView(header.renderbody()) print(body.renderbody()) action = input(body.rendernavigation()) if action.upper() in valid_answers: result = valid_answers[action] else: result = 'controllers.errorcontroller' breadcrumbs.stack_navigation('controllers.homecontroller') return result
def test_password(self, verification): verifications = {"short": {"input": "qwe1", "outcome": "Password should be not less then 6 symbols."}, "mismatch": {"input": "mismatch1234", "outcome": "Password confirmation doesn\'t match password."}} home = HomeView(self.driver) home.request_password_icon.click() home.chat_request_input.send_keys(verifications[verification]["input"]) home.confirm() if 'short' not in verification: home.chat_request_input.send_keys("qwerty1234") home.confirm() home.find_full_text(verifications[verification]["outcome"])
def test_one_to_one_chat(self): device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) set_password_as_new_user(device_1, device_2) device_1.back_button.click() chats_d1 = device_1.get_chats() chats_d1.profile_button.click() profile_d1 = chats_d1.profile_icon.click() key = profile_d1.public_key_text.text device_2.back_button.click() chats_d2 = device_2.get_chats() chats_d2.plus_button.click() chats_d2.add_new_contact.click() chats_d2.public_key_edit_box.send_keys(key) chats_d2.confirm() chats_d2.confirm_public_key_button.click() message_1 = 'SOMETHING' message_2 = 'another SOMETHING' user_d1_name = chats_d2.user_name_text.text chats_d2.chat_message_input.send_keys(message_1) chats_d2.send_message_button.click() chats_d1.back_button.click() chats_d1.find_full_text(message_1) one_to_one_chat_d1 = chats_d1.element_by_text(message_1, 'button') one_to_one_chat_d1.click() one_to_one_chat_d2 = chats_d2.element_by_text(user_d1_name, 'button') one_to_one_chat_d2.click() chats_d2.chat_message_input.send_keys(message_2) chats_d2.send_message_button.click() chats_d1.find_full_text(message_2)
def test_private_chat(self): device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) set_chat_for_users_from_scratch(device_1, device_2) device_1.back_button.click() chats_d1 = device_1.get_chats() chats_d1.profile_button.click() profile_d1 = chats_d1.profile_icon.click() key = profile_d1.public_key_text.get_key() device_2.back_button.click() chats_d2 = device_2.get_chats() chats_d2.plus_button.click() chats_d2.add_new_contact.click() chats_d2.public_key_edit_box.send_keys(key) chats_d2.confirm() chats_d2.confirm_public_key_button.click() chats_d2.chat_message_input.send_keys('SOMETHING') chats_d2.send_message_button.click() profile_d1.back_button.click() profile_d1.find_text('SOMETHING')
1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.conf.urls import url from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import path from views.post import PostDetailedView, PostCreateView, PostUpdateView from views.home import HomeView from views.moderator import ModeratorView from views.user import UserCreateView, UserLoginView urlpatterns = [ path('admin/', admin.site.urls), url(r'^$', HomeView.as_view(), name="home"), url(r'^new-post/$', PostCreateView.as_view(), name="post_new"), url(r'^new-user/$', UserCreateView.as_view(), name="user_new"), url(r'^moderator/$', ModeratorView.as_view(), name="moderator"), url(r'^login/', UserLoginView.as_view(), name="user_login"), url(r'^(?P<slug>[\w-]+)/$', PostDetailedView.as_view(), name="detailed"), url(r'^edit/(?P<slug>[\w-]+)/$', PostUpdateView.as_view(), name="post_edit"), ] urlpatterns += staticfiles_urlpatterns()
from flask import Blueprint, render_template from views.admin import LoginView, LogoutView, RegisterView, AdminIndexView from views.home import HomeView, HomeCategoryView, HomeNewsView main = Blueprint('main', __name__) @main.app_errorhandler(404) def page_not_found(error): return render_template('404.html') main.add_url_rule('/', view_func=HomeView.as_view('home'), methods=['GET']) # admin main.add_url_rule('/admin/', view_func=AdminIndexView.as_view('admin'), methods=['GET']) main.add_url_rule('/register/', view_func=RegisterView.as_view('register'), methods=['GET', 'POST']) main.add_url_rule('/login/', view_func=LoginView.as_view('login'), methods=['GET', 'POST']) main.add_url_rule('/logout/', view_func=LogoutView.as_view('logout'), methods=['GET']) main.add_url_rule('/category/<int:cid>/', view_func=HomeCategoryView.as_view('category'), methods=['GET']) main.add_url_rule('/news/<nid>/', view_func=HomeNewsView.as_view('news'), methods=['GET'])
def make_listview(self, data): header = self.make_header() self.home_view = HomeView(data, header) return self.home_view
def test_group_chat_send_receive_messages_and_remove_user(self): device_1, device_2 = HomeView(self.driver_1), \ HomeView(self.driver_2) set_password_as_new_user(device_2, device_1) device_1.back_button.click() chats_d1 = device_1.get_chats() chats_d1.profile_button.click() profile_d1 = chats_d1.profile_icon.click() key = profile_d1.public_key_text.text device_2.back_button.click() chats_d2 = device_2.get_chats() chats_d2.plus_button.click() chats_d2.add_new_contact.click() chats_d2.public_key_edit_box.send_keys(key) chats_d2.confirm() chats_d2.confirm_public_key_button.click() user_name_d1 = chats_d2.user_name_text.text device_2.back_button.click() chats_d2.new_group_chat_button.click() user_contact = chats_d2.element_by_text(user_name_d1, 'button') user_contact.scroll_to_element() user_contact.click() chats_d2.next_button.click() chat_name = 'new_chat' message_1 = 'first SOMETHING' message_2 = 'second SOMETHING' message_3 = 'third SOMETHING' chats_d2.name_edit_box.send_keys(chat_name) chats_d2.save_button.click() # send_and_receive_messages chats_d2.chat_message_input.send_keys(message_1) chats_d2.send_message_button.click() profile_d1.back_button.click() chats_d1 = profile_d1.get_chats() chats_d1.find_full_text(message_1) group_chat_d1 = chats_d1.element_by_text(chat_name, 'button') group_chat_d1.click() chats_d2.chat_message_input.send_keys(message_2) chats_d2.send_message_button.click() chats_d1.find_full_text(message_2) # remove_user chats_d2.group_chat_options.click() chats_d2.chat_settings.click() chats_d2.confirm() chats_d2.user_options.click() chats_d2.remove_button.click() device_2.back_button.click() # chats_d2.find_full_text("You\'ve removed " + user_name_d1) chats_d2.chat_message_input.send_keys(message_3) chats_d2.send_message_button.click() chats_d1.find_text_part("removed you from group chat") message_text = chats_d1.element_by_text(message_3, 'text') if message_text.is_element_present(20): pytest.fail( 'Message is shown for the user which has been removed from the GroupChat', False)
from config import app, db, HOST, PORT, DEBUG from views.login import LoginView from views.user_registration import UserRegisterationView from views.event_registration import EventRegisterationView from views.home import HomeView from views.about import AboutView from views.logout import LogoutView from views.event import EventView # Routes app.add_url_rule('/', view_func=HomeView.as_view('home')) app.add_url_rule('/about', view_func=AboutView.as_view('about')) app.add_url_rule('/event/<int:id>', view_func=EventView.as_view('event')) app.add_url_rule('/user_registeration', view_func=UserRegisterationView.as_view('user_registeration')) app.add_url_rule( '/event_registeration', view_func=EventRegisterationView.as_view('event_registeration')) app.add_url_rule('/login', view_func=LoginView.as_view('login')) app.add_url_rule('/logout', view_func=LogoutView.as_view('logout')) if __name__ == "__main__": db.create_all() app.run(HOST, PORT, DEBUG)
import api admin.autodiscover() urlpatterns = [ # Imported URLs url(r'^admin/', include(admin.site.urls)), url(r'^api/', include(api.router.urls)), # Homepage url(r'^$', HomeView.as_view(), name='home'), # Representative list url( r'^representatives/$', RepresentativeList.as_view(), name='representative-list' ), # Representative detail url( r'^representatives/(?P<slug>[-\w]+)/$', RedirectRepresentativeDetail.as_view(), name='representative-detail'
from views.theme_list import ThemeList from .legacy_urls import urlpatterns as legacy_patterns import api admin.autodiscover() urlpatterns = [ # Imported URLs url(r'^admin/', include(admin.site.urls)), url(r'^api/', include(api.router.urls)), # Homepage url(r'^$', HomeView.as_view(), name='home'), # Representative list url(r'^representatives/$', RepresentativeList.as_view(), name='representative-list'), # Representative detail url(r'^representatives/(?P<slug>[-\w]+)/$', RedirectRepresentativeDetail.as_view(), name='representative-detail'), url(r'^representatives/(?P<slug>[-\w]+)/votes/$', RepresentativeDetailVotes.as_view(), name='representative-votes'), url(r'^representatives/(?P<slug>[-\w]+)/mandates/$', RepresentativeDetailMandates.as_view(),