Beispiel #1
0
def test_bucket_create_new_bucket():
    """
    Tests InvestmentBucket.create_new_bucket()
    """
    user1 = User.objects.create(username='******', password="******")
    user2 = User.objects.create(username='******', password="******")
    assert user1.profile.owned_bucket.count() == 0
    InvestmentBucket.create_new_bucket(name="Bucket1",
                                       public=True,
                                       owner=user1.profile)
    InvestmentBucket.create_new_bucket(name="Bucket2",
                                       public=True,
                                       owner=user2.profile)
    assert user1.profile.owned_bucket.count() == 1
Beispiel #2
0
def test_change_bucket_composition(selenium, live_server, client):
    """
    Test selling a bucket
    """
    user = User.objects.create_user('temporary', '*****@*****.**', 'temporary')
    user.save()
    user.userbank.create(
        item_id='dummy1', access_token='dummy2',
        institution_name='dummy3', current_balance_field=0,
        account_name_field="dummy4", income_field=0,
        expenditure_field=0
    )
    stock = Stock(
        name="Name1", ticker="poooooop"
    )
    stock.save()
    stock.daily_quote.create(
        value=1000, date="2016-03-03"
    )
    client.login(username='******', password='******')
    cookie = client.cookies['sessionid']
    buck = InvestmentBucket.create_new_bucket(
        name="IAMATESTBUCKET",
        public=True,
        owner=user.profile)
    buck.save()
    InvestmentStockConfiguration(quantity=1, stock=stock, bucket=buck, start="2016-03-03").save()
    assert user.profile.owned_bucket.count() == 1
    user.profile.default_acc().trade_bucket(buck, .01)
    selenium.get('%s%s' % (live_server, '/login'))
    selenium.add_cookie({
        'name': 'sessionid',
        'value': cookie.value,
        'secure': False,
        'path': '/',
    })
    selenium.get('%s%s' % (live_server, '/home'))
    selenium.implicitly_wait(10)
    edit_button = selenium.find_element_by_id("edit-comp")
    edit_button.click()
    slider = selenium.find_element_by_class_name("rc-slider-handle-2")
    actions = ActionChains(selenium)
    actions.click_and_hold(slider)
    actions.move_by_offset(-100, 0)
    actions.release(slider)
    actions.perform()
    save_composition = selenium.find_element_by_xpath("//button[contains(.,'Save')]")
    save_composition.click()
    time.sleep(1)
    assert buck.stocks.count() == 2
Beispiel #3
0
def test_bucket_add_stock(selenium, live_server, client):
    """
    Test adding stock to bucket
    """
    user = User.objects.create_user('temporary', '*****@*****.**', 'temporary')
    user.save()
    user.userbank.create(
        item_id='dummy1', access_token='dummy2',
        institution_name='dummy3', current_balance_field=0,
        account_name_field="dummy4", income_field=0,
        expenditure_field=0
    )
    stock = Stock(
        name="Name1", ticker="poooooop"
    )
    stock.save()
    stock.daily_quote.create(
        value=10000, date="2016-03-03"
    )
    client.login(username='******', password='******')
    cookie = client.cookies['sessionid']
    buck = InvestmentBucket.create_new_bucket(
        name="IAMATESTBUCKET", public=True,
        owner=user.profile)
    buck.save()
    assert user.profile.owned_bucket.count() == 1
    selenium.get('%s%s' % (live_server, '/login'))
    selenium.add_cookie({
        'name': 'sessionid',
        'value': cookie.value,
        'secure': False,
        'path': '/',
    })
    selenium.get('%s%s' % (live_server, '/home'))
    selenium.implicitly_wait(30)
    bucket = user.profile.owned_bucket.get(name="IAMATESTBUCKET")
    assert bucket.get_stock_configs().count() == 0
    edit_button = selenium.find_element_by_id("edit-comp")
    edit_button.click()
    stock_field = selenium.find_element_by_id("stockname")
    stock_field.send_keys("Name1")
    add_stock = selenium.find_element_by_id("add-stock")
    add_stock.click()
    save_composition = selenium.find_element_by_xpath("//button[contains(.,'Save')]")
    save_composition.click()
    assert bucket.get_stock_configs().count() == 1
Beispiel #4
0
def test_add_attr_to_bucket(selenium, live_server, client):
    """
    Test adding attr to bucket
    """
    user = User.objects.create_user('temporary', '*****@*****.**', 'temporary')
    user.save()
    user.userbank.create(
        item_id='dummy1', access_token='dummy2',
        institution_name='dummy3', current_balance_field=0,
        account_name_field="dummy4", income_field=0,
        expenditure_field=0
    )
    client.login(username='******', password='******')
    assert user.profile.owned_bucket.count() == 0
    cookie = client.cookies['sessionid']
    buck = InvestmentBucket.create_new_bucket(
        name="IAMATESTBUCKET", public=True,
        owner=user.profile)
    buck.save()
    assert user.profile.owned_bucket.count() == 1
    selenium.get('%s%s' % (live_server, '/login'))
    selenium.add_cookie({
        'name': 'sessionid',
        'value': cookie.value,
        'secure': False,
        'path': '/',
    })
    selenium.get('%s%s' % (live_server, '/home'))
    selenium.implicitly_wait(30)
    add_attr = selenium.find_element_by_id("launch-edit")
    add_attr.click()
    attr_field = selenium.find_element_by_id("name")
    attr_field.send_keys("poooooop")
    attr_field.send_keys(Keys.RETURN)
    time.sleep(1)
    bucket = user.profile.owned_bucket.get(name="IAMATESTBUCKET")
    assert bucket.description.get(text="poooooop").text == "poooooop"
    assert bucket.description.get(text="poooooop").is_good
    assert bucket.description.count() == 1
    attr = selenium.find_element_by_id("attr")
    assert "poooooop" in attr.text
Beispiel #5
0
def test_delete_bucket(selenium, live_server, client):
    """
    Tests deleting a bucket
    """
    user = User.objects.create_user('temporary', '*****@*****.**', 'temporary')
    user.save()
    user.userbank.create(
        item_id='dummy1', access_token='dummy2',
        institution_name='dummy3', current_balance_field=0,
        account_name_field="dummy4", income_field=0,
        expenditure_field=0
    )
    client.login(username='******', password='******')
    assert user.profile.owned_bucket.count() == 0
    cookie = client.cookies['sessionid']
    buck = InvestmentBucket.create_new_bucket(
        name="IAMATESTBUCKET", public=True,
        owner=user.profile)
    buck.save()
    assert user.profile.owned_bucket.count() == 1
    selenium.get('%s%s' % (live_server, '/login'))
    selenium.add_cookie({
        'name': 'sessionid',
        'value': cookie.value,
        'secure': False,
        'path': '/',
    })
    selenium.get('%s%s' % (live_server, '/home'))
    selenium.implicitly_wait(30)
    delete_button = selenium.find_element_by_id("delete")
    delete_button.click()
    cancel_delete = selenium.find_element_by_id("keep")
    cancel_delete.click()
    WebDriverWait(selenium, 10).until(
        EC.invisibility_of_element_located((By.ID, "keep"))
    )
    assert user.profile.owned_bucket.count() == 1
    delete_button.click()
    confirm_delete = selenium.find_element_by_id("delete2")
    confirm_delete.click()
    assert user.profile.owned_bucket.count() == 0