def test_use_bbox_instead_of_lat_long(self): # Arrange lat = 1 long = 2 bbox = [59.811225, 20.623165, 70.07531, 31.569525] bot = EverywordBot("consumer_key", "consumer_secret", "access_token", "token_secret", "test/test_source.txt", "index_file", lat=lat, long=long, bbox=bbox) bot._get_current_line = lambda index: "word" stub = TwitterStub() bot.twitter.update_status = stub.twitter_update_status # Act bot.post() # Assert self.assertNotEqual(stub.lat, 1) self.assertNotEqual(stub.long, 2) self.assertTrue(bbox[0] <= stub.lat <= bbox[2]) self.assertTrue(bbox[1] <= stub.long <= bbox[3])
def test__post(self): # Arrange bot = EverywordBot("consumer_key", "consumer_secret", "access_token", "token_secret", "test/test_source.txt", "test/test_index.txt") bot.twitter.update_status = stub_twitter_update_status index_before = bot._get_current_index() # Act bot.post() # Assert index_after = bot._get_current_index() self.assertEqual(index_before + 1, index_after)
def test__prefix(self): # Arrange bot = EverywordBot("consumer_key", "consumer_secret", "access_token", "token_secret", "test/test_source.txt", "index_file", prefix="aardvark ") bot._get_current_line = lambda index: "word" stub = TwitterStub() bot.twitter.update_status = stub.twitter_update_status # Act bot.post() # Assert self.assertEqual(stub.status, "aardvark word")
def test__post(self): # Arrange bot = EverywordBot("consumer_key", "consumer_secret", "access_token", "token_secret", "test/test_source.txt", "test/test_index.txt") stub = TwitterStub() bot.twitter.update_status = stub.twitter_update_status index_before = bot._get_current_index() # Act bot.post() # Assert index_after = bot._get_current_index() self.assertEqual(index_before + 1, index_after)
def test__suffix(self): # Arrange bot = EverywordBot("consumer_key", "consumer_secret", "access_token", "token_secret", "test/test_source.txt", "index_file", suffix=" zebra") bot._get_current_line = lambda index: "word" stub = TwitterStub() bot.twitter.update_status = stub.twitter_update_status # Act bot.post() # Assert self.assertEqual(stub.status, "word zebra")