def student_map_response(request, course_population_by_country_code, template, course_id): top_countries = sorted( [(population, code, get_country_name(code)) for code, population in course_population_by_country_code.iteritems()], reverse=True ) if request.GET.get("format") == "csv": data_rows = [(country, population) for population, _code, country in top_countries] return csv_response(["country", "enrollments"], data_rows, "countries.csv") total_population = sum(course_population_by_country_code.values()) return render(request, template, { "active_tab": "student_map", "course_id": course_id, "course_population": course_population_by_country_code, "top_countries": top_countries, "total_population": total_population, })
def test_get_country_name(self): self.assertEqual(_("France"), countries.get_country_name('FR')) self.assertEqual(_("Unknown"), countries.get_country_name(countries.UNKNOWN_COUNTRY_CODE))
def test_get_country_name(self): self.assertEqual(_("France"), countries.get_country_name('FR')) self.assertEqual( _("Unknown"), countries.get_country_name(countries.UNKNOWN_COUNTRY_CODE))