<reponame>Ayrtonfoster/325_project<filename>CI-Python/q325_test/integration/test_posting.py
import pytest
from seleniumbase import BaseCase

from q325_test.conftest import base_url
from datetime import date, timedelta

dateTime = date.today()
dateTime = dateTime + timedelta(days=10)
future_date = dateTime.strftime("%Y-%m-%d")
format_date = dateTime.strftime("%Y-%m-%d")


@pytest.mark.usefixtures('server')
class IntegrationPostingTest(BaseCase):

    def register_and_login(self, email, user, password):

        # register
        self.open(base_url + '/register')
        self.type("#email", email)
        self.type("#name", user)
        self.type("#password", password)
        self.type("#password2", password)
        self.click('input[type="submit"]')

        # log in
        self.open(base_url + '/login')
        self.type('#email', email)
        self.type('#password', password)
        self.click('input[type="submit"]')

    def test_posting(self, *_):
        """
        Test that user can post a ticket for sale, using full system from login through logout
        """

        self.register_and_login('<EMAIL>', 'test user', '<PASSWORD>')

        # post a ticket for sale
        self.type("#sell_ticket_name", "PostingTestTicket")
        self.type("#sell_num_tickets", "15")
        self.type("#sell_ticket_price", "15")
        self.type("#sell_ticket_date", future_date)  # use date that is ahead of today's date
        self.click('input[id="sell_btn-submit"]')

        # Check for posted ticket in table
        self.driver.find_element_by_id('PostingTestTicket%15%15%' + format_date + '%<EMAIL>')

        # check that url is /sell
        self.assertEqual(self.get_current_url(), base_url + "/sell")

        # logout
        self.open(base_url + '/logout')

import pytest
from seleniumbase import BaseCase

from q325_test.conftest import base_url
from datetime import date, timedelta

dateTime = date.today()
dateTime = dateTime + timedelta(days=10)
future_date = dateTime.strftime("%Y-%m-%d")
format_date = dateTime.strftime("%Y-%m-%d")


@pytest.mark.usefixtures('server')
class IntegrationPostingTest(BaseCase):

    def register_and_login(self, email, user, password):

        # register
        self.open(base_url + '/register')
        self.type("#email", email)
        self.type("#name", user)
        self.type("#password", password)
        self.type("#password2", password)
        self.click('input[type="submit"]')

        # log in
        self.open(base_url + '/login')
        self.type('#email', email)
        self.type('#password', password)
        self.click('input[type="submit"]')

    def test_posting(self, *_):
        """
        Test that user can post a ticket for sale, using full system from login through logout
        """

        self.register_and_login('<EMAIL>', 'test user', '<PASSWORD>')

        # post a ticket for sale
        self.type("#sell_ticket_name", "PostingTestTicket")
        self.type("#sell_num_tickets", "15")
        self.type("#sell_ticket_price", "15")
        self.type("#sell_ticket_date", future_date)  # use date that is ahead of today's date
        self.click('input[id="sell_btn-submit"]')

        # Check for posted ticket in table
        self.driver.find_element_by_id('PostingTestTicket%15%15%' + format_date + '%<EMAIL>')

        # check that url is /sell
        self.assertEqual(self.get_current_url(), base_url + "/sell")

        # logout
        self.open(base_url + '/logout')
# register # log in Test that user can post a ticket for sale, using full system from login through logout # post a ticket for sale # use date that is ahead of today's date # Check for posted ticket in table # check that url is /sell # logout