Skip to content

Commit

Permalink
Merge e995e9e into 0e3253f
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasulejoseph committed Sep 10, 2018
2 parents 0e3253f + e995e9e commit c646ae0
Show file tree
Hide file tree
Showing 776 changed files with 207,715 additions and 30 deletions.
1 change: 1 addition & 0 deletions .coverage
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/kasule/Desktop/levelUp/Tests/test_register.py":[64,1,2,4,7,8,9,10,11,13,17,19,23,24,26,27,28,30,31,32,34,38,39,40,42,65,46,47,48,50,54,56,57,59,60,61,63],"/home/kasule/Desktop/levelUp/Tests/__init__.py":[1],"/home/kasule/Desktop/levelUp/Tests/register.py":[1,2,3,4,5,7,8,9,11,13,15,16,17,19,21,23,24,25,27]}}
1 change: 1 addition & 0 deletions .coveralls.yml
@@ -0,0 +1 @@
repo_token: vNbuPyDup5tZFw5xqhMoVmPfWOzel2PeH
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
__pycache__/
challenge.txt
env/
.vscode/
.vscode/
*.pyc
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
language: python

python:
- "3.6"

# install dependency
install:
- pip install -r requirement.txt
- pip install coveralls

script:
- coverage run -m unittest Tests/test_register.py -v
- coverage report -m
after_success:
- coveralls
30 changes: 6 additions & 24 deletions README.md
@@ -1,29 +1,11 @@
<<<<<<< HEAD
## KiVULU EVENT TICKETS (KETs)
# KiVULU EVENT TICKETS (KETs)
is an online application for granting digital tickets to people who are
eligible to attend the scheduled event.

=======
Challenge:
------------
Imagine you are at an event reception desk; when someone arrives to attend,
you are charged with checking if a user registered for the event and in
which category.Given two text files, one containing names of people
who registered for the event in the VIP category and the second contains
those that signed up for ORDINARY tickets.Your program should:
- Read the files, and store the contents in lists.
- Ask a user to enter one of their names and check through the lists to see
> if a user paid for a ticket
> if the ticket paid for, is an Ordinary or Vip ticketSpecs:
## Build Status

Name your main function registration_checker, its argument/input should
be a single name
For example; For the name Maria, it should return a Full name, Category
i.e Maria Nanfuka, VIP
For the name Edison, it should return Not Registered
Put your file (reception.py) in an importable folder named reception
within the project directory.
[![Build Status](https://travis-ci.com/Kasulejoseph/Ticket-App.svg?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/Kasulejoseph/Ticket-App/badge.svg?branch=develop)](https://coveralls.io/github/Kasulejoseph/Ticket-App?branch=develop)

view the home page UI on the [gh-pages](https://kasulejoseph.github.io/Ticket-App/)

** Your Git and Pivotal Tracker usage is of a high priority (edited)
vip_list.txt
>>>>>>> reception
57 changes: 57 additions & 0 deletions TDD/challenge.txt
@@ -0,0 +1,57 @@
Challenge:
------------
Imagine you are at an event reception desk; when someone arrives to attend,
you are charged with checking if a user registered for the event and in
which category.Given two text files, one containing names of people
who registered for the event in the VIP category and the second contains
those that signed up for ORDINARY tickets.Your program should:
- Read the files, and store the contents in lists.
- Ask a user to enter one of their names and check through the lists to see
> if a user paid for a ticket
> if the ticket paid for, is an Ordinary or Vip ticketSpecs:

Name your main function registration_checker, its argument/input should
be a single name
For example; For the name Maria, it should return a Full name, Category
i.e Maria Nanfuka, VIP
For the name Edison, it should return Not Registered
Put your file (reception.py) in an importable folder named reception
within the project directory.

** Your Git and Pivotal Tracker usage is of a high priority (edited)
vip_list.txt


ordinary_list.txt



from reception.reception import vip,ordinary
m = vip()
print(m)





# def registrationCkecker(fnames,vip,ordinary):
# print()
# # if fnames.lower() == fname.lower():
# # print ("Name : " + fnames + ' ' + lname +", Category: VIP")
# # if fnames.lower() == fname.lower():
# # print ("Name : " + fnames + ' ' + lname +", Category: Ordinary")
# # print("not found")
# registrationCkecker(fnames = input("Enter name: "))


# f = open("vip.txt", "r")
# r = f.readlines()
# for n in r:
# list.append(n.split())
# print(n.split()[0])


# print(list)
# for element in list:
# print(element[0])

29 changes: 29 additions & 0 deletions TDD/index.html
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="keywords" lang="en-us" content="events, plot, night life">
<meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="HandheldFriendly" content ="true">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Events App</title>
</head>
<body>
<div id="nav"><h1>BATALO EAST EVENT TICKET</h1></div>
<div id="register">
<form action="" method="POST">
<span>First Name:</span>
<input type="text" name="name" placeholder="Name"><br>
<span>Last Name:</span>
<input type="text" name="name" placeholder="Name"><br>
<span>Email:</span>
<input type="email" name="email" placeholder="Email">
<br>
<input type="submit" value="Book Ticket">
</form>
</div>

</body>
</html>
12 changes: 12 additions & 0 deletions TDD/signUp.py
@@ -0,0 +1,12 @@
class SignUp():
def __init__(self):
self.user_bio = dict()
def add(self, username, password):
self.user_bio[username] = password

def get_password(self, username):
return self.user_bio[username]

def length_of_bio(self, username,password):
self.user_bio[username] = password
return
30 changes: 30 additions & 0 deletions TDD/test_signup.py
@@ -0,0 +1,30 @@
import unittest
from signUp import SignUp
class SignUpTest(unittest.TestCase):

def test_signup_creation(self):
signup = SignUp()
self.assertIsInstance(signup, SignUp)
def test_add_user(self):
signup = SignUp()
signup.add("john doe", "john@gmail.com")
self.assertEquals(len(signup.user_bio),1)

def test_return_password(self):
signup = SignUp()
signup.add("john", "12345")
self.assertEqual(signup.get_password("john"), "12345")

def test_missing_key(self):
signup = SignUp()
with self.assertRaises(KeyError):
signup.get_password("jo")

def test_length_of_bio(self):
signup = SignUp()
signup.user_bio("john doe", "john@gmail.com")
self.assertEqual(len(signup.user_bio), 7)

# skip test
# @unittest.skip(WIP)
# def test_unknown()
Binary file removed Tests/__pycache__/register.cpython-35.pyc
Binary file not shown.
Binary file removed Tests/__pycache__/test_register.cpython-35.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion Tests/register.py
Expand Up @@ -3,19 +3,22 @@ def __init__(self):
self.fname = dict()
self.lname = dict()
self.emails = dict()

def firstName(self,name,firstname):
self.fname[name] = firstname
if not isinstance(self.fname[name], str):
raise TypeError("Value should be a string")
if len(self.fname[name]) < 4:
raise ValueError("name should have more than 4 characters" )
raise ValueError("name should have more than 4 characters" )
return self.fname

def lastName(self,name,lastname):
self.lname[name] = lastname
if not isinstance(self.lname[name], str):
raise TypeError("value should be a string")
if len(self.lname[name]) < 4:
raise ValueError("few character inputs" )
return self.lname

def email(self,mail,address):
self.emails[mail] = address
Expand Down
12 changes: 10 additions & 2 deletions Tests/test_register.py
@@ -1,5 +1,5 @@
import unittest
from register import signUp
from .register import signUp

class testRegister(unittest.TestCase):

Expand Down Expand Up @@ -55,4 +55,12 @@ def test_for_valid_email(self):

def test_email_invalid(self):
self.assertNotEqual(self.signup.emails["mail"],"kasule@gmail")


def test_isinstance(self):
self.signup.fname["name"]= 343
self.assertRaises(TypeError, "Value should be a string")

def test_islength_less_than_four(self):
cal_len = self.signup.fname["name"]
self.assertTrue(len(cal_len)>4)

25 changes: 25 additions & 0 deletions app/gezesa.py
@@ -0,0 +1,25 @@
from reception.reception import vip,ordinary
def registrationCkecker(fnames):
ordin = ordinary()
VIP = vip()
try:
for name in VIP:
fname = name[0]
lname = name[1]
if fnames.lower() == fname.lower():
print ("Name : " + fnames + ' ' + lname +", Category: VIP")

except expression as identifier:
for name in ordin:
fname = name[0]
lname = name[1]
if fnames.lower() == fname.lower():
print ("Name : " + fnames + ' ' + lname +", Category: Ordinary")
print("dsf")
print("in")

registrationCkecker(fnames = input("Enter name: "))


line = [line.strip() for line in f]
names = [[word.lower() for word in test.split()]for test in line]
Binary file removed app/reception/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file removed app/reception/__pycache__/reception.cpython-35.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions app2/__init__.py
@@ -0,0 +1,4 @@
from flask import Flask
from app2.main.views import main
app = Flask(__name__)
app.register_blueprint(main)
4 changes: 4 additions & 0 deletions app2/main/__init__.py
@@ -0,0 +1,4 @@
from flask import Blueprint,Flask
app = Flask(__name__)
main = Blueprint('main', __name__)
from . import views
40 changes: 40 additions & 0 deletions app2/main/views.py
@@ -0,0 +1,40 @@
from flask import Flask, request, jsonify, Blueprint
main = Blueprint('main', __name__)
def all_users():
user_list = [
{'musoke':
[{"user_id":1,"Fullnames":"musoke innocent", 'password':'male'}]},

{'ivan':
[{"user_id":2,"Fullnames":"ivan kivumbi", 'password':'password'}]},
{'hassan':
[{"user_id":3,"Fullnames":"hassan innocent", 'password':'computer'}]},
{'mary':
[{"user_id":4,"Fullnames":"mary Gorret", 'password':'mary'}]}
]
return user_list

user_list = all_users()
@main.route('/api/user/add', methods = ['POST'])
def add_users():
data = request.get_json()
details = data.get('details')
if details in user_list:
return jsonify({"error": "User already added"}), 400
user_list.append(details)
return jsonify({'new_user': user_list}), 201

@main.route('/api/user/get', methods =['GET'])
def get_users():
if len(user_list)==0:
return jsonify({"message": "no learners available"}),404
return jsonify ({"Users":user_list, "number":len(user_list)}),200

@main.route('/api/user/delete', methods=['DELETE'])
def delete_user():
data = request.get_json()
details= data.get('details')
if details in user_list:
user_list.remove(details)
return jsonify({'new_user': user_list}), 200
return jsonify({"error":"user not found in the list "}), 400

0 comments on commit c646ae0

Please sign in to comment.