def test_backend_cleanup_entitity_getters(django_user_model, admin_user, random_namespace_name): run_minikube_sync() admin_user.last_login = parse("2017-09-23 11:21:52.909020 +02:00") admin_user.save() ns = KubernetesNamespace(name=random_namespace_name) ns.save() assert admin_user in django_user_model.inactive_users() assert ns in KubernetesNamespace.without_pods() assert ns in KubernetesNamespace.without_service_accounts()
def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['site_header'] = settings.BRANDING + " (Admin Backend)" context['title'] = "Clean Up" context[ 'namespaces_no_service_acc'] = KubernetesNamespace.without_service_accounts( ) context['namespaces_no_pods'] = KubernetesNamespace.without_pods() context['months'] = settings.LAST_LOGIN_MONTHS_AGO context['inactive_users'] = User.inactive_users() return context
def test_backend_cleanup_entitity_getters(): User = get_user_model() from django.utils import dateparse # we need an inactive user for the the filter to work u = User(username="******", email="*****@*****.**", last_login=dateparse.parse_datetime( "2017-09-23 11:21:52.909020 +02.00")) u.save() ns = KubernetesNamespace(name="asdfadfasdfasdf", visible=True) ns.save() assert (User.inactive_users()[0] == User.objects.get( username=u.username)) assert (KubernetesNamespace.without_pods()[0] == ns) assert (KubernetesNamespace.without_service_accounts()[0] == ns)