Example #1
0
 def test_get_row_file(self):
     unlocode = "AUN7K"
     if "MYSQL_EP" in main.CONFIG:
         del main.CONFIG["MYSQL_EP"]
     main.CONFIG["MYSQL_FILE"] = "dataset/unlocode_list_with_gps.csv"
     result = main.get_row(unlocode)
     self.assertIsNotNone(result)
     self.assertEqual(result.lat, -37.31)
     self.assertEqual(result.lng, 145.21)
Example #2
0
    def test_mainSomething(self):
        unlocode = "AUN7K"

        row_from_db = main.get_row(unlocode)
        self.assertEqual([row_from_db.lat, row_from_db.lng], [-37.31, 145.21])

        timezone = main.get_timezone(row_from_db)
        self.assertEqual(timezone, "Australia/Melbourne")

        returnvalue = row_from_db.__dict__

        returnvalue["timezone"] = timezone
        returnvalue["current_time"] = main.get_local_time(returnvalue)

        print(returnvalue["current_time"])  ## 2019-02-20T10:54:26+11:00
        self.assertTrue("+11:00" in returnvalue["current_time"]
                        or "+10:00" in returnvalue["current_time"])

        return returnvalue
Example #3
0
    def test_mainSomething2(self):
        unlocode = "USHOU"

        row_from_db = main.get_row(unlocode)
        self.assertEqual([row_from_db.lat, row_from_db.lng], [29.45, -95.21])

        timezone = main.get_timezone(row_from_db)
        self.assertEqual(timezone, "America/Chicago")

        returnvalue = row_from_db.__dict__

        returnvalue["timezone"] = timezone
        returnvalue["current_time"] = main.get_local_time(returnvalue)

        print(returnvalue["current_time"])  ## 2019-02-20T10:54:26+11:00
        self.assertTrue(
            "-05:00" in returnvalue["current_time"]
            or "-06:00" in returnvalue["current_time"])  # Added DST

        return returnvalue
Example #4
0
    def test_DaylightSavings2Timestamp(self):
        unlocode = "USSFO"
        timestamp = "2018-03-12T03:58:40-00:00"

        row_from_db = main.get_row(unlocode)
        self.assertEqual([row_from_db.lat, row_from_db.lng], [37.77, -122.41])

        timezone = main.get_timezone(row_from_db)
        self.assertEqual(timezone, "America/Los_Angeles")

        returnvalue = row_from_db.__dict__

        returnvalue["timezone"] = timezone
        returnvalue["current_time"] = main.get_local_time(
            returnvalue, timestamp)

        # print(returnvalue["current_time"])  ## 2018-03-11T20:58:40-07:00
        self.assertTrue("-07:00" in returnvalue["current_time"])

        return returnvalue
Example #5
0
    def test_DaylightSavings2Epoch(self):
        unlocode = "USSFO"
        timestampInEpoch = int("1554465520000")

        row_from_db = main.get_row(unlocode)
        self.assertEqual([row_from_db.lat, row_from_db.lng], [37.77, -122.41])

        timezone = main.get_timezone(row_from_db)
        self.assertEqual(timezone, "America/Los_Angeles")

        returnvalue = row_from_db.__dict__

        returnvalue["timezone"] = timezone
        returnvalue["current_time"] = main.get_local_time(
            returnvalue, timestampInEpoch)

        # print(returnvalue["current_time"])  ## 2019-04-05T04:58:40-07:00
        self.assertTrue("-07:00" in returnvalue["current_time"])

        return returnvalue
Example #6
0
 def test_get_row(self):
     unlocode = "AUN7K"
     result = main.get_row(unlocode)
     self.assertIsNotNone(result)
     self.assertEqual(result.lat, -37.31)
     self.assertEqual(result.lng, 145.21)
Example #7
0
 def test_sql_credentials_missing(self):
     main.CONFIG = {}
     unlocode = "USHOU"
     row_from_db = main.get_row(unlocode)
     self.assertEqual(row_from_db, "no connection string")
Example #8
0
 def test_unlocode_total(
         self):  # tests that there are five characters total
     unlocode = "USHOU"
     row_from_db = main.get_row(unlocode)
     self.assertEqual(len(row_from_db.id), 5)
Example #9
0
 def test_incorrect_unlocode(
     self
 ):  #tests for incorrect unlocode input ex. user inputs HOUST instead of USHOU
     unlocode = "HOUST"
     row_from_db = main.get_row(unlocode)
     self.assertIsNone(row_from_db)
Example #10
0
 def test_example_row(self):
     result = main.get_row('FBFBBFFRLR')
     self.assertEqual(result, 44)