Exemplo n.º 1
0
    def test_time_after_kick_off(self):

        dt = datetime.now() - timedelta(hours=1)
        test_kick_off = datetime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
        test_kick_off_string = datetime.strftime(test_kick_off, "%Y-%m-%d %H:%M:%S")
        row = (
            2,
            test_kick_off_string,
            u"Tottenham Hotspur",
            u"Manchester United",
            u"White Hart Lane, London",
            u"premier-league",
            0,
        )
        m = Match(row)

        self.assertAlmostEquals(m.time_after_kick_off(), 60, 0)
Exemplo n.º 2
0
def main():
    #First create three employers' questionnaires:
    #Starbucks, TGI Friday and Hillton
    '''
    e1 = Question('[ { "Id": "1", "Question": "Do you have high school diploma", "Answer": "yes" }, \
    { "Id": "2", "Question": "What was your main duty", "Answer": "barista" }, \
    { "Id": "3", "Question": "Do you have driver license", "Answer": "yes" }]', 'Starbucks')
    e2 = Question('[ { "Id": "1", "Question": "Do you have high school diploma", "Answer": "yes" }, \
    { "Id": "2", "Question": "What was your main duty", "Answer": "bartender" }, \
    { "Id": "3", "Question": "Do you have driver license", "Answer": "yes" }]', 'TGI Friday')
    e3 = Question('[ { "Id": "1", "Question": "Do you have high school diploma", "Answer": "yes" }, \
    { "Id": "2", "Question": "What was your main duty", "Answer": "front desk" }, \
    { "Id": "3", "Question": "Do you have driver license", "Answer": "yes" }]', 'Hilton')
    
    #Then write them into dynamodb 'Questions' table (one employer per row)
    put_list_item(e1.check_question(), 'Questions')
    put_list_item(e2.check_question(), 'Questions')
    put_list_item(e3.check_question(), 'Questions')
    '''
    #Second, create three applicantions
    a1 = Applicant(
        '{ "Name": "Jack Doe",  "Questions": [ {  "Id": "1", "Answer": "yes" }, \
    {  "Id": "2", "Answer": "barista" }, {"Id": "3", "Answer": "yes" }] }')
    a2 = Applicant(
        '{ "Name": "John Smith",  "Questions": [ {  "Id": "1", "Answer": "yes" }, \
    {  "Id": "2", "Answer": "bartender" }, {"Id": "3", "Answer": "yes" }] }')
    a3 = Applicant(
        '{ "Name": "Cathy Bell",  "Questions": [ {  "Id": "1", "Answer": "yes" }, \
    {  "Id": "2", "Answer": "front desk" }, {"Id": "3", "Answer": "yes" }] }')

    #Then check their applications (all correct)
    m1 = Match('Starbucks', a1.check_application()).match_questions()
    m2 = Match('TGI Friday', a2.check_application()).match_questions()
    m3 = Match('Hilton', a3.check_application()).match_questions()
    print("m1: %s, m2: %s, m3: %s" % (m1, m2, m3))
    with open('reult.txt', 'a') as f:
        for n in [m1, m2, m3]:
            if n[0]:
                f.write(n[1] + '\n')

    #Then check more applications (all incorrect, wrong questionnaire)
    m1 = Match('TGI Friday', a1.check_application()).match_questions()
    m2 = Match('Starbucks', a2.check_application()).match_questions()
    m3 = Match('Starbucks', a3.check_application()).match_questions()
    print("m1: %s, m2: %s, m3: %s" % (m1, m2, m3))
    with open('result.txt', 'a') as f:
        for n in [m1, m2, m3]:
            if n[0]:
                f.write(n[1] + '\n')

    #Create application with incorrect answer
        a4 = Applicant(
            '{ "Name": "Amy Wong",  "Questions": [ {  "Id": "1", "Answer": "yes" }, \
    {  "Id": "2", "Answer": "engineer" }, {"Id": "3", "Answer": "yes" }] }')
    m4 = Match('Starbucks', a4.check_application()).match_questions()
    print(m4)
Exemplo n.º 3
0
    def setUp(self):

        self.dt = datetime.now() - timedelta(hours=-1)
        self.test_kick_off = datetime(
            self.dt.year, self.dt.month, self.dt.day, self.dt.hour, self.dt.minute, self.dt.second
        )
        self.test_kick_off_string = datetime.strftime(self.test_kick_off, "%Y-%m-%d %H:%M:%S")
        row = (
            2,
            self.test_kick_off_string,
            u"Tottenham Hotspur",
            u"Manchester United",
            u"White Hart Lane, London",
            u"premier-league",
            0,
        )
        self.m = Match(row)
Exemplo n.º 4
0
class TestMatch(unittest.TestCase):
    def setUp(self):

        self.dt = datetime.now() - timedelta(hours=-1)
        self.test_kick_off = datetime(
            self.dt.year, self.dt.month, self.dt.day, self.dt.hour, self.dt.minute, self.dt.second
        )
        self.test_kick_off_string = datetime.strftime(self.test_kick_off, "%Y-%m-%d %H:%M:%S")
        row = (
            2,
            self.test_kick_off_string,
            u"Tottenham Hotspur",
            u"Manchester United",
            u"White Hart Lane, London",
            u"premier-league",
            0,
        )
        self.m = Match(row)

    def test_stats_url(self):
        stats_url_template = "http://www.guardian.co.uk/football/match/{0}/{1}/{2}/{3}-v-{4}"

        self.assertEquals(
            self.m.stats_url,
            stats_url_template.format(
                self.m.kick_off.year,
                datetime.strftime(self.m.kick_off, "%b").lower(),
                str(self.m.kick_off.day).zfill(2),
                self.m.home_url,
                self.m.away_url,
            ),
        )

    def test_events_url(self):
        events_url_template = "http://www.guardian.co.uk/football/match-popup/{0}/{1}/{2}/{3}-v-{4}"

        self.assertEquals(
            self.m.events_url,
            events_url_template.format(
                self.m.kick_off.year,
                datetime.strftime(self.m.kick_off, "%b").lower(),
                str(self.m.kick_off.day).zfill(2),
                self.m.home_url,
                self.m.away_url,
            ),
        )

    def test_home_team(self):
        self.assertIsInstance(self.m.home_team, unicode)
        self.assertEquals(self.m.home_team, u"Tottenham Hotspur")

    def test_away_team(self):
        self.assertIsInstance(self.m.away_team, unicode)
        self.assertEquals(self.m.away_team, u"Manchester United")

    def test_venue(self):
        self.assertIsInstance(self.m.venue, unicode)
        self.assertEquals(self.m.venue, u"White Hart Lane, London")

    def test_datetime(self):
        self.assertIsInstance(self.m.kick_off, datetime)
        self.assertEquals(self.m.kick_off, self.test_kick_off)

    def test_played(self):
        self.assertFalse(self.m.played)

    def test_time_until_kick_off(self):
        self.assertAlmostEquals(self.m.time_until_kick_off(), 60, 0)

    def test_time_after_kick_off(self):

        dt = datetime.now() - timedelta(hours=1)
        test_kick_off = datetime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
        test_kick_off_string = datetime.strftime(test_kick_off, "%Y-%m-%d %H:%M:%S")
        row = (
            2,
            test_kick_off_string,
            u"Tottenham Hotspur",
            u"Manchester United",
            u"White Hart Lane, London",
            u"premier-league",
            0,
        )
        m = Match(row)

        self.assertAlmostEquals(m.time_after_kick_off(), 60, 0)