Example #1
0
    def test_Explore_Theater_Theater_filter(self):

        user_service = UserService()

        filters = {
            'city': "",
            'selectedState': None,
            'selectedCompany': '4400 Theater Company',
            'selectedTheater': 'Star Movies'
        }

        actual = user_service.ExploreTheater(filters)

        expected = [{
            'comName': '4400 Theater Company',
            'thName': 'Star Movies',
            'thStreet': '4400 Rocks Ave',
            'thCity': 'Boulder',
            'thState': 'CA',
            'thZipcode': '80301'
        }]

        assert len(actual) == len(expected)

        assert sorted(actual,
                      key=functools.cmp_to_key(compare_theater)) == sorted(
                          expected, key=functools.cmp_to_key(compare_theater))
Example #2
0
    def test_Explore_Theater_CityFilter(self):

        user_service = UserService()

        filters = {
            'city': "New York",
            'selectedState': None,
            'selectedCompany': None,
            'selectedTheater': None
        }

        actual = user_service.ExploreTheater(filters)

        expected = [
            {
                'comName': "EZ Theater Company",
                'thName': "Main Movies",
                'thStreet': "123 Main St",
                'thCity': "New York",
                'thState': 'NY',
                'thZipcode': '10001'
            },
        ]

        assert len(actual) == len(expected)

        assert sorted(actual,
                      key=functools.cmp_to_key(compare_theater)) == sorted(
                          expected, key=functools.cmp_to_key(compare_theater))
Example #3
0
    def test_logVisit(self):

        user_service = UserService()

        filters = {
            'i_thname': 'Cinema Star',
            'i_coname': '4400 Theater Company',
            'i_visitdate': '2019-11-24T01:38:50.493Z'
        }

        date = dateutil.parser.parse(filters['i_visitdate']).date()

        user_name = 'georgep'

        length = 0

        connection = get_conn()
        with connection.cursor() as cursor:
            leng = "select visitID from UserVisitTheater"
            cursor.execute(leng)
            length = cursor.fetchall()
            connection.commit()
        connection.close()

        new_id = len(length) + 1

        user_service.LogVisit(user_name, filters)

        connection = get_conn()
        with connection.cursor() as cursor:
            info = """select visitID, username, thName, comName, visitDate from UserVisitTheater where
          visitID=(%s) and username=(%s)
          and thName=(%s)
          and comName=(%s)
          and visitDate=(%s)"""
            cursor.execute(info, (new_id, user_name, filters['i_thname'],
                                  filters['i_coname'], date))
            data = cursor.fetchall()
            connection.commit()

            sql_del = """delete From UserVisitTheater where visitID = (%s)"""
            cursor.execute(sql_del, (new_id))
            connection.commit()

        connection.close()

        assert len(data) == 1
Example #4
0
    def test_visit_history_empty(self):
        filterz = {}

        connection = get_conn()
        with connection.cursor() as cursor:

            user_service = UserService()

            user_service.VisitHistory('calcwizard', filterz)

            cursor.execute(
                "select * from UserVisitTheater where username='******'")
            data = cursor.fetchall()
            connection.commit()

        connection.close()

        assert len(data) == 3
Example #5
0
    def test_Explore_Theater_Bad_state(self):

        user_service = UserService()

        filters = {
            'city': "New York",
            'selectedState': 'AL',
            'selectedCompany': None,
            'selectedTheater': None
        }

        actual = user_service.ExploreTheater(filters)

        expected = []

        assert len(actual) == len(expected)

        assert sorted(actual,
                      key=functools.cmp_to_key(compare_theater)) == sorted(
                          expected, key=functools.cmp_to_key(compare_theater))
Example #6
0
    def test_Explore_Theater_Company_Filter(self):

        user_service = UserService()

        filters = {
            'city': "",
            'selectedState': None,
            'selectedCompany': '4400 Theater Company',
            'selectedTheater': None
        }

        actual = user_service.ExploreTheater(filters)

        expected = [{
            'comName': '4400 Theater Company',
            'thName': 'Cinema Star',
            'thStreet': '100 Cool Place',
            'thCity': 'San Francisco',
            'thState': 'CA',
            'thZipcode': '94016'
        }, {
            'comName': '4400 Theater Company',
            'thName': 'Star Movies',
            'thStreet': '4400 Rocks Ave',
            'thCity': 'Boulder',
            'thState': 'CA',
            'thZipcode': '80301'
        }, {
            'comName': '4400 Theater Company',
            'thName': "Jonathan's Movies",
            'thStreet': '67 Pearl Dr',
            'thCity': 'Seattle',
            'thState': 'WA',
            'thZipcode': '98101'
        }]

        assert len(actual) == len(expected)

        assert sorted(actual,
                      key=functools.cmp_to_key(compare_theater)) == sorted(
                          expected, key=functools.cmp_to_key(compare_theater))
Example #7
0
    def test_visit_history(self):
        filterz = {
            'i_comName': '4400 Theater Company',
            'i_minVisitDate': datetime.date(2005, 11, 25),
            'i_maxVisitDate': datetime.date(2012, 11, 30)
        }

        connection = get_conn()
        with connection.cursor() as cursor:

            user_service = UserService()

            user_service.VisitHistory('imready', filterz)

            cursor.execute(
                "select * from UserVisitTheater where username='******'")
            data = cursor.fetchall()
            connection.commit()

        connection.close()

        assert len(data) == 1
Example #8
0
    def test_Explore_Theater_NoFilters(self):

        user_service = UserService()

        filters = {
            'city': "",
            'selectedState': None,
            'selectedCompany': None,
            'selectedTheater': None
        }

        actual = user_service.ExploreTheater(filters)

        expected = [{
            'comName': "EZ Theater Company",
            'thName': "Main Movies",
            'thStreet': "123 Main St",
            'thCity': "New York",
            'thState': 'NY',
            'thZipcode': '10001'
        }, {
            'comName': "EZ Theater Company",
            'thName': 'Star Movies',
            'thStreet': '745 GT St',
            'thCity': 'Atlanta',
            'thState': 'GA',
            'thZipcode': '30332'
        }, {
            'comName': '4400 Theater Company',
            'thName': 'Cinema Star',
            'thStreet': '100 Cool Place',
            'thCity': 'San Francisco',
            'thState': 'CA',
            'thZipcode': '94016'
        }, {
            'comName': '4400 Theater Company',
            'thName': 'Star Movies',
            'thStreet': '4400 Rocks Ave',
            'thCity': 'Boulder',
            'thState': 'CA',
            'thZipcode': '80301'
        }, {
            'comName': '4400 Theater Company',
            'thName': "Jonathan's Movies",
            'thStreet': '67 Pearl Dr',
            'thCity': 'Seattle',
            'thState': 'WA',
            'thZipcode': '98101'
        }, {
            'comName': 'Awesome Theater Company',
            'thName': 'ABC Theater',
            'thStreet': '880 Color Dr',
            'thCity': 'Austin',
            'thState': 'TX',
            'thZipcode': '73301'
        }, {
            'comName': 'AI Theater Company',
            'thName': 'ML Movies',
            'thStreet': '314 Pi St',
            'thCity': 'Pallet Town',
            'thState': 'KS',
            'thZipcode': '31415'
        }]

        assert len(actual) == len(expected)

        assert sorted(actual,
                      key=functools.cmp_to_key(compare_theater)) == sorted(
                          expected, key=functools.cmp_to_key(compare_theater))
Example #9
0
root = logging.getLogger()
root.addHandler(handler)

app = Flask(__name__, static_folder="build/static", template_folder="build")
CORS(app)
app.config['EXPLAIN_TEMPLATE_LOADING'] = True

db_reset()

# create services
login_service = LoginService()
register_service = RegisterService()
manager_service = ManagerService()
drop_down_service = DropDownService()
user_service = UserService()
customer_service = CustomerService()
admin_service = AdminService()


#-----------Main------------
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
    return render_template('index.html')


#------------LOGIN------------
@app.route('/userLogin', methods=['POST'])
def userLogin():
    data = request.get_json()