archive test for now

This commit is contained in:
SpudGunMan
2024-06-27 11:15:52 -07:00
parent 1dde4112da
commit da659b42d0
5 changed files with 1 additions and 164 deletions
-46
View File
@@ -1,46 +0,0 @@
import unittest
from unittest import mock
from bbstools import *
class TestBBSListMessages(unittest.TestCase):
def test_bbs_list_messages(self):
# Mock the bbs_messages list
bbs_messages = [[1, "Welcome to meshBBS", "Welcome to the BBS, please post a message!",0],
[2, "Test Message 1", "This is a test message 1",0],
[3, "Test Message 2", "This is a test message 2",0]]
# Mock the return value of bbs_messages
with mock.patch('bbstools.bbs_messages', bbs_messages):
expected_output = "Msg #1 Welcome to meshBBS\nMsg #2 Test Message 1\nMsg #3 Test Message 2"
self.assertEqual(bbs_list_messages(), expected_output)
def test_bbs_post_message(self):
subject = "Test Subject"
message = "Test Message"
with mock.patch('bbstools.bbs_messages', [[1, "Welcome to meshBBS", "Welcome to the BBS, please post a message!"]]):
result = bbs_post_message(subject, message)
expected_output = "Message posted. ID is: 2" # Assuming there is already one message in the list
self.assertEqual(result, expected_output)
expected_output = "Msg #1 Welcome to meshBBS\nMsg #2 Test Subject" # Assuming there is already one message in the list
self.assertEqual(bbs_list_messages(), expected_output)
def test_bbs_delete_message(self):
# Mock the bbs_messages list
bbs_messages = [[1, "Welcome to meshBBS", "Welcome to the BBS, please post a message!",0],
[2, "Test Message 1", "This is a test message 1",0],
[3, "Test Message 2", "This is a test message 2",0]]
# Mock the return value of bbs_messages
with mock.patch('bbstools.bbs_messages', bbs_messages):
result = bbs_delete_message(2)
expected_output = "Msg #2 deleted."
self.assertEqual(result, expected_output)
expected_output = "Msg #1 Welcome to meshBBS\nMsg #2 Test Message 2"
self.assertEqual(bbs_list_messages(), expected_output)
if __name__ == '__main__':
unittest.main()
-101
View File
@@ -1,101 +0,0 @@
import unittest
from locationdata import *
class TestGetWeather(unittest.TestCase):
def test_get_weather_with_valid_coordinates(self):
# Test with valid coordinates
lat = "37.7749"
lon = "-122.4194"
weather = get_weather(lat, lon)
print(f"weather: {weather}")
self.assertNotEqual(weather, NO_DATA_NOGPS)
self.assertNotEqual(weather, ERROR_FETCHING_DATA)
# test replacement works
self.assertNotIn(weather, "Sunday")
self.assertNotIn(weather, "Monday")
self.assertNotIn(weather, "Tuesday")
self.assertNotIn(weather, "Wednesday")
self.assertNotIn(weather, "Thursday")
self.assertNotIn(weather, "Friday")
self.assertNotIn(weather, "Saturday")
self.assertNotIn(weather, "northwest")
self.assertNotIn(weather, "northeast")
self.assertNotIn(weather, "southwest")
self.assertNotIn(weather, "southeast")
self.assertNotIn(weather, "north")
self.assertNotIn(weather, "south")
self.assertNotIn(weather, "east")
self.assertNotIn(weather, "west")
self.assertNotIn(weather, "precipitation")
self.assertNotIn(weather, "showers")
self.assertNotIn(weather, "thunderstorms")
def test_get_weather_with_invalid_coordinates(self):
# Test with invalid coordinates
lat = 0
lon = 0
weather = get_weather(lat, lon)
print(f"weather: {weather}")
self.assertEqual(weather, NO_DATA_NOGPS)
def test_where_am_i_with_valid_coordinates(self):
# Test with invalid coordinates
lat = "37.7749"
lon = "-122.4194"
location = where_am_i(lat, lon)
print(f"location: {location}")
self.assertEqual(location, "South Van Ness Avenue San Francisco California 94103 United States Grid: CM87ss")
self.assertNotEqual(location, NO_DATA_NOGPS)
self.assertNotEqual(location, ERROR_FETCHING_DATA)
def test_get_tide_with_valid_coordinates(self):
# Test with valid coordinates
lat = "37.7749"
lon = "-122.4194"
tide = get_tide(lat, lon)
print(f"tide: {tide}")
self.assertNotEqual(tide, NO_DATA_NOGPS)
self.assertNotEqual(tide, ERROR_FETCHING_DATA)
def test_replace_weather(self):
# Test replacing days of the week
self.assertEqual(replace_weather("Monday"), "Mon ")
self.assertEqual(replace_weather("Tuesday"), "Tue ")
self.assertEqual(replace_weather("Wednesday"), "Wed ")
self.assertEqual(replace_weather("Thursday"), "Thu ")
self.assertEqual(replace_weather("Friday"), "Fri ")
self.assertEqual(replace_weather("Saturday"), "Sat ")
# Test replacing time periods
self.assertEqual(replace_weather("Today"), "Today ")
self.assertEqual(replace_weather("Tonight"), "Tonight ")
self.assertEqual(replace_weather("Tomorrow"), "Tomorrow ")
self.assertEqual(replace_weather("This Afternoon"), "Afternoon ")
# Test replacing directions
self.assertEqual(replace_weather("northwest"), "NW")
self.assertEqual(replace_weather("northeast"), "NE")
self.assertEqual(replace_weather("southwest"), "SW")
self.assertEqual(replace_weather("southeast"), "SE")
self.assertEqual(replace_weather("north"), "N")
self.assertEqual(replace_weather("south"), "S")
self.assertEqual(replace_weather("east"), "E")
self.assertEqual(replace_weather("west"), "W")
self.assertEqual(replace_weather("Northwest"), "NW")
self.assertEqual(replace_weather("Northeast"), "NE")
self.assertEqual(replace_weather("Southwest"), "SW")
self.assertEqual(replace_weather("Southeast"), "SE")
self.assertEqual(replace_weather("North"), "N")
self.assertEqual(replace_weather("South"), "S")
self.assertEqual(replace_weather("East"), "E")
self.assertEqual(replace_weather("West"), "W")
# Test replacing weather terms
self.assertEqual(replace_weather("precipitation"), "precip")
self.assertEqual(replace_weather("showers"), "shwrs")
self.assertEqual(replace_weather("thunderstorms"), "t-storms")
if __name__ == '__main__':
unittest.main()