def setup(options: list): """Assigns the options to argv(as if JobFunnel were called from the command line with those options) and calls parse_config(). This fixture assumes that the test_parse module has been tested and passes. """ with patch.object(sys, 'argv', options): config = parse_config() return config
def test_user_yaml(tmpdir): # create temporary settings file and write yaml file yaml_file = Path(tmpdir) / 'settings.yaml' with open(yaml_file, mode='w') as f: yaml.dump(config_dict, f) # call funnel with user-defined settings with patch.object(sys, 'argv', ['', '-s', str(yaml_file)]): config = parse_config() assert config['output_path'] == "fish" assert set(config['providers']) == set(['indeed', 'monster']) assert config['search_terms']['region']['state'] == 'NY' # assert config['search_terms']['region']['province'] == 'NY' # I believe this should pass assert config['search_terms']['region']['city'] == 'New York' assert config['search_terms']['region']['domain'] == 'com' assert config['search_terms']['region']['radius'] == 25
with open(cities_america, 'r') as file: cities_america = json.load(file) with open(cities_canada, 'r') as file: cities_canada = json.load(file) cities = cities_america + cities_canada test_size = 100 if len(cities) < test_size: test_size = len(cities) # take a random sample of cities of size test_size cities = random.sample(cities, test_size) with patch.object(sys, 'argv', ['']): config = parse_config() @pytest.mark.xfail(strict=False) @pytest.mark.parametrize('city', cities) def test_cities(city, delay=1): """tests american city""" count = 0 # a count of providers with successful test cases for p in config['providers']: provider: Union[GlassDoorStatic, Monster, Indeed] = PROVIDERS[p](config) provider.search_terms['region']['domain'] = DOMAINS[city['country']] provider.search_terms['region']['province'] = city['abbreviation'] provider.search_terms['region']['city'] = city['city'] if isinstance(provider, Indeed): # get search url
def test_cli_yaml(): with patch.object(sys, 'argv', cli_options[1]): config = parse_config() assert config['output_path'] == '.' with patch.object(sys, 'argv', cli_options[2]): config = parse_config() assert config['search_terms']['keywords'] == ['java', 'python'] with patch.object(sys, 'argv', cli_options[3]): config = parse_config() assert config['search_terms']['region']['province'] == 'ON' with patch.object(sys, 'argv', cli_options[4]): config = parse_config() assert config['search_terms']['region']['city'] == 'New York' with patch.object(sys, 'argv', cli_options[5]): config = parse_config() assert config['search_terms']['region']['domain'] == 'com' with patch.object(sys, 'argv', cli_options[6]): config = parse_config() assert config['delay_config']['random'] is True with patch.object(sys, 'argv', cli_options[7]): config = parse_config() assert config['delay_config']['converge'] is True with patch.object(sys, 'argv', cli_options[8]): config = parse_config() assert config['delay_config']['delay'] == 20 with patch.object(sys, 'argv', cli_options[9]): config = parse_config() assert config['delay_config']['min_delay'] == 10 with patch.object(sys, 'argv', cli_options[10]): config = parse_config() assert config['delay_config']['function'] == 'linear' with patch.object(sys, 'argv', cli_options[11]): config = parse_config() assert config['log_level'] == log_levels['info'] with patch.object(sys, 'argv', cli_options[12]): config = parse_config() assert config['similar'] is True with patch.object(sys, 'argv', cli_options[13]): config = parse_config() assert config['no_scrape'] is True with patch.object(sys, 'argv', cli_options[14]): config = parse_config() assert config['proxy'] == { 'protocol': 'http', 'ip_address': '50.193.9.202', 'port': '53888' }