def test_generate_gmail_filter_set(self): with open(os.path.join(os.path.dirname(__file__), 'data', 'user_recipe_set.yml')) as f: filter_set = generate_gmail_fitler_set( UserRecipeSet.wrap(yaml.load(f)), updated_timestamp=datetime.datetime(2014, 10, 27, 2, 20, 58) ) with open(os.path.join(os.path.dirname(__file__), 'data', 'filters.xml')) as f: expected_xml = f.read() self.assertXmlEqual(filter_set.to_xml(pretty=True), expected_xml)
def test_generate_gmail_filter_set(self): with open( os.path.join(os.path.dirname(__file__), 'data', 'user_recipe_set.yml')) as f: filter_set = generate_gmail_fitler_set( UserRecipeSet.wrap(yaml.load(f)), updated_timestamp=datetime.datetime(2014, 10, 27, 2, 20, 58)) with open( os.path.join(os.path.dirname(__file__), 'data', 'filters.xml')) as f: expected_xml = f.read() self.assertXmlEqual(filter_set.to_xml(pretty=True), expected_xml)
def filters_xml(): bottle.response.headers.update({ 'Content-Type': 'application/xml; charset="utf-8"', 'Content-Disposition': 'attachment; filename="gmailFilters.xml"', }) recipe_set_json = ( bottle.request.json or json.loads(bottle.request.POST.get('recipeSet')) ) user_recipe_set = UserRecipeSet.wrap(recipe_set_json) gmail_filter_set = generate_gmail_fitler_set(user_recipe_set) return gmail_filter_set.to_xml(pretty=True)