コード例 #1
0
ファイル: test_geocoder.py プロジェクト: jtbwedgwood/bbd
	def test_GeocodeLocations_test_real_geocoder(self, tmp_path):
		"""Tests the .run() and associated methods with a real geocoder
		"""
		p = tmp_path/"test.csv"

		gl = gc.GeocodeLocations(self.address_df, valid_email, p,
		                         batch_size = 1)
		gl.run(num_batches=3)

		assert all(gl.locations.all())
コード例 #2
0
ファイル: test_geocoder.py プロジェクト: jtbwedgwood/bbd
	def test_GeocodeLocatios_make_file_header(self, tmp_path):
		"""Tests the ._make_file() and ._make_header() methods
		for GeocodeLocations
		"""
		p = tmp_path/"test.csv"

		gl = gc.GeocodeLocations(self.address_df, valid_email, p)

		test = pd.read_csv(p, sep = "\t")

		error_msg = "Saved File has improper header."
		assert "latitude" in test.columns, error_msg
		assert "longitude" in test.columns, error_msg
		assert "address" in test.columns, error_msg
		assert len(test.columns) <= 4, error_msg
コード例 #3
0
ファイル: test_geocoder.py プロジェクト: jtbwedgwood/bbd
	def test_GeocodeLocations_reset(self, tmp_path):
		"""
		"""
		#Mocks the input asking for DELETE
		gc.input = lambda *args : "DELETE"

		p = tmp_path/"test.csv"

		gl = gc.GeocodeLocations(self.address_df, valid_email, p)
		gl._set_test_geocoder()

		gl.run()

		gl.reset()

		test = pd.read_csv(p, sep = "\t")

		assert test.empty, "File was not deleted"
		assert gl.curr_batch == 1, "Batches were not reset"
		assert len(gl._queue) == 234, "Queue was not reset"
コード例 #4
0
ファイル: test_geocoder.py プロジェクト: jtbwedgwood/bbd
	def test_GeocodeLocations_run_one_batch(self, tmp_path):
		"""Tests the .run() and associated methods for
		GeocodeLocations.
		"""
		p = tmp_path/"test.csv"

		gl = gc.GeocodeLocations(self.address_df, valid_email, p)
		gl._set_test_geocoder()

		gl.run()

		test = pd.read_csv(p, sep = "\t")

		assert not test.empty, "No results saved to disk."
		assert not gl.locations.empty, "No results stored in object."

		assert len(test) == 234, "Not all lines were saved to disk"
		assert len(gl.locations) == 234, "Not all lines were saved in object"

		assert len(test.columns) <= 4, "Saved too many columns in tsv format"
コード例 #5
0
ファイル: test_geocoder.py プロジェクト: jtbwedgwood/bbd
	def test_GeocodeLocations_address_dict(self, tmp_path):
		"""Tests the .run() and associated methods when constructing df from
		list of dicts.
		"""
		p = tmp_path/"test.csv"

		gl = gc.GeocodeLocations(self.address_dict, valid_email, p,
		                         batch_size = 100)
		gl._set_test_geocoder()

		gl.run()

		test = pd.read_csv(p, sep = "\t")

		assert gl.tot_batches == 3, "Batches are not constructed properly."

		assert not test.empty, "No results saved to disk."
		assert not gl.locations.empty, "No results stored in object."

		assert len(test) == 234, "Not all lines were saved to disk."
		assert len(gl.locations) == 234, "Not all lines were saved in object."
コード例 #6
0
ファイル: test_geocoder.py プロジェクト: jtbwedgwood/bbd
	def test_GeocodeLocations_run_less_than_all_batches(self, tmp_path):
		"""Tests the .run() and associated methods for GeocodeLocations when
		running less than all batches. 
		"""
		p = tmp_path/"test.csv"

		gl = gc.GeocodeLocations(self.address_df, valid_email, p,
		                         batch_size = 100)
		gl._set_test_geocoder()

		gl.run(num_batches = 1)

		test = pd.read_csv(p)

		assert gl.tot_batches == 3, "Batches are not constructed properly."
		assert gl.curr_batch < 3, "Run running too many batches."

		assert not test.empty, "No results saved to disk."
		assert not gl.locations.empty, "No results stored in object."

		assert len(test) < 234, "Not all lines were saved to disk."
		assert len(gl.locations) < 234, "Not all lines were saved in object."