def test_fill_city_2(monkeypatch): pca = Pca('', '', '朝阳区') mo_map = mock_map(monkeypatch, 'area_map', '北京市') cpca._fill_city(pca, {}) mo_map.get_value.assert_called_once_with(pca.area, C) assert pca.city == '北京市'
def test_fill_province(monkeypatch): pca = Pca('', '淮安市', '') # 猴子补丁 mo_map = mock_map(monkeypatch, 'city_map', '江苏省') cpca._fill_province(pca) mo_map.get_value.assert_called_once_with(pca.city, P) assert pca.province == "江苏省" assert pca.city == '淮安市'
def test_fill_city_3(monkeypatch): pca = Pca('江苏省', '', '鼓楼区') mock_map(monkeypatch, 'area_map', '', is_contain=True, is_unique_value=False) mo_map = mock_map(monkeypatch, 'province_area_map', '南京市') cpca._fill_city(pca, {}) mo_map.get_value.assert_called_once_with(('江苏省', '鼓楼区'), C) assert pca.city == '南京市'
def test_fill_city_1(): pca = Pca('', '', '朝阳区') cpca._fill_city(pca, {'朝阳区': '北京市'}) assert pca.city == '北京市'
def test_region_code(): '''区域编码获取''' pca = Pca('福建省', '厦门市', '湖里区') print(pca.region_code) assert pca.region_code == '1156350200'
def setup_class(cls): from cpca.structures import Pca cls.pca = Pca('安徽省', '合肥市', '肥东区', 0, 3, 7) cls.pca1 = Pca("浙江省", "丽水市", "青田县")